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
There are still many places where import paths with `..` are used and maybe should use absolute paths also.
24 lines
925 B
TypeScript
24 lines
925 B
TypeScript
import block from '@/services/blocking/create.js';
|
|
import { CacheableRemoteUser } from '@/models/entities/user.js';
|
|
import { Users } from '@/models/index.js';
|
|
import DbResolver from '@/remote/activitypub/db-resolver.js';
|
|
import { IBlock } from '@/remote/activitypub/type.js';
|
|
|
|
export default async (actor: CacheableRemoteUser, activity: IBlock): Promise<string> => {
|
|
// ※ activity.objectにブロック対象があり、それは存在するローカルユーザーのはず
|
|
|
|
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 block(await Users.findOneByOrFail({ id: actor.id }), await Users.findOneByOrFail({ id: blockee.id }));
|
|
return 'ok';
|
|
};
|