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.
22 lines
771 B
TypeScript
22 lines
771 B
TypeScript
import unblock from '@/services/blocking/delete.js';
|
|
import { IRemoteUser } from '@/models/entities/user.js';
|
|
import { Users } from '@/models/index.js';
|
|
import { IBlock } from '@/remote/activitypub/type.js';
|
|
import { DbResolver } from '@/remote/activitypub/db-resolver.js';
|
|
|
|
export default async (actor: IRemoteUser, activity: IBlock): Promise<string> => {
|
|
const dbResolver = new DbResolver();
|
|
const blockee = await dbResolver.getUserFromApId(activity.object);
|
|
|
|
if (blockee == null) {
|
|
return 'skip: blockee not found';
|
|
}
|
|
|
|
if (blockee.host != null) {
|
|
return 'skip: ブロック解除しようとしているユーザーはローカルユーザーではありません';
|
|
}
|
|
|
|
await unblock(await Users.findOneByOrFail({ id: actor.id }), blockee);
|
|
return 'ok';
|
|
};
|