FoundKey/packages/backend/src/remote/activitypub/kernel/undo/block.ts
Johann150 36a0e48e49
All checks were successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
bacakend: prefer absolute over relative imports
There are still many places where import paths with `..` are used and
maybe should use absolute paths also.
2022-10-01 14:40:30 +02:00

22 lines
783 B
TypeScript

import unblock from '@/services/blocking/delete.js';
import { CacheableRemoteUser } 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: CacheableRemoteUser, 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';
};