diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/process/process-flag.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/server/lib/activitypub/process/process-flag.ts b/server/lib/activitypub/process/process-flag.ts index 8d1c9c869..1d7132a3a 100644 --- a/server/lib/activitypub/process/process-flag.ts +++ b/server/lib/activitypub/process/process-flag.ts | |||
@@ -1,4 +1,9 @@ | |||
1 | import { ActivityCreate, ActivityFlag, VideoAbuseState } from '../../../../shared' | 1 | import { |
2 | ActivityCreate, | ||
3 | ActivityFlag, | ||
4 | VideoAbuseState, | ||
5 | videoAbusePredefinedReasonsMap | ||
6 | } from '../../../../shared' | ||
2 | import { VideoAbuseObject } from '../../../../shared/models/activitypub/objects' | 7 | import { VideoAbuseObject } from '../../../../shared/models/activitypub/objects' |
3 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 8 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
4 | import { logger } from '../../../helpers/logger' | 9 | import { logger } from '../../../helpers/logger' |
@@ -38,13 +43,21 @@ async function processCreateVideoAbuse (activity: ActivityCreate | ActivityFlag, | |||
38 | 43 | ||
39 | const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: object }) | 44 | const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: object }) |
40 | const reporterAccount = await sequelizeTypescript.transaction(async t => AccountModel.load(account.id, t)) | 45 | const reporterAccount = await sequelizeTypescript.transaction(async t => AccountModel.load(account.id, t)) |
46 | const tags = Array.isArray(flag.tag) ? flag.tag : [] | ||
47 | const predefinedReasons = tags.map(tag => videoAbusePredefinedReasonsMap[tag.name]) | ||
48 | .filter(v => !isNaN(v)) | ||
49 | const startAt = flag.startAt | ||
50 | const endAt = flag.endAt | ||
41 | 51 | ||
42 | const videoAbuseInstance = await sequelizeTypescript.transaction(async t => { | 52 | const videoAbuseInstance = await sequelizeTypescript.transaction(async t => { |
43 | const videoAbuseData = { | 53 | const videoAbuseData = { |
44 | reporterAccountId: account.id, | 54 | reporterAccountId: account.id, |
45 | reason: flag.content, | 55 | reason: flag.content, |
46 | videoId: video.id, | 56 | videoId: video.id, |
47 | state: VideoAbuseState.PENDING | 57 | state: VideoAbuseState.PENDING, |
58 | predefinedReasons, | ||
59 | startAt, | ||
60 | endAt | ||
48 | } | 61 | } |
49 | 62 | ||
50 | const videoAbuseInstance: MVideoAbuseAccountVideo = await VideoAbuseModel.create(videoAbuseData, { transaction: t }) | 63 | const videoAbuseInstance: MVideoAbuseAccountVideo = await VideoAbuseModel.create(videoAbuseData, { transaction: t }) |