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.
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { In } from 'typeorm';
|
|
import config from '@/config/index.js';
|
|
import { genId } from '@/misc/gen-id.js';
|
|
import { CacheableRemoteUser } from '@/models/entities/user.js';
|
|
import { AbuseUserReports, Users } from '@/models/index.js';
|
|
import { IFlag, getApIds } from '@/remote/activitypub/type.js';
|
|
|
|
export default async (actor: CacheableRemoteUser, activity: IFlag): Promise<string> => {
|
|
// objectは `(User|Note) | (User|Note)[]` だけど、全パターンDBスキーマと対応させられないので
|
|
// 対象ユーザーは一番最初のユーザー として あとはコメントとして格納する
|
|
const uris = getApIds(activity.object);
|
|
|
|
const userIds = uris.filter(uri => uri.startsWith(config.url + '/users/')).map(uri => uri.split('/').pop()!);
|
|
const users = await Users.findBy({
|
|
id: In(userIds),
|
|
});
|
|
if (users.length < 1) return 'skip';
|
|
|
|
await AbuseUserReports.insert({
|
|
id: genId(),
|
|
createdAt: new Date(),
|
|
targetUserId: users[0].id,
|
|
targetUserHost: users[0].host,
|
|
reporterId: actor.id,
|
|
reporterHost: actor.host,
|
|
comment: activity.content,
|
|
urls: uris.filter(uri => !uri.startsWith(config.url + '/users/')),
|
|
});
|
|
|
|
return 'ok';
|
|
};
|