forked from FoundKeyGang/FoundKey
Johann150
1516ddfc9b
The CacheableUser, CacheableLocalUser and CacheableRemoteUser are identical types to User, ILocalUser and IRemoteUser so it seems nonsensical to have different types for them.
27 lines
760 B
TypeScript
27 lines
760 B
TypeScript
import unfollow from '@/services/following/delete.js';
|
|
import { IRemoteUser } from '@/models/entities/user.js';
|
|
import { Followings } from '@/models/index.js';
|
|
import { DbResolver } from '@/remote/activitypub/db-resolver.js';
|
|
import { IAccept } from '@/remote/activitypub/type.js';
|
|
|
|
export default async (actor: IRemoteUser, activity: IAccept): Promise<string> => {
|
|
const dbResolver = new DbResolver();
|
|
|
|
const follower = await dbResolver.getUserFromApId(activity.object);
|
|
if (follower == null) {
|
|
return 'skip: follower not found';
|
|
}
|
|
|
|
const following = await Followings.countBy({
|
|
followerId: follower.id,
|
|
followeeId: actor.id,
|
|
});
|
|
|
|
if (following) {
|
|
await unfollow(follower, actor);
|
|
return 'ok: unfollowed';
|
|
}
|
|
|
|
return 'skip: not followed';
|
|
};
|