aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process/process-flag.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/process/process-flag.ts')
-rw-r--r--server/lib/activitypub/process/process-flag.ts17
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 @@
1import { ActivityCreate, ActivityFlag, VideoAbuseState } from '../../../../shared' 1import {
2 ActivityCreate,
3 ActivityFlag,
4 VideoAbuseState,
5 videoAbusePredefinedReasonsMap
6} from '../../../../shared'
2import { VideoAbuseObject } from '../../../../shared/models/activitypub/objects' 7import { VideoAbuseObject } from '../../../../shared/models/activitypub/objects'
3import { retryTransactionWrapper } from '../../../helpers/database-utils' 8import { retryTransactionWrapper } from '../../../helpers/database-utils'
4import { logger } from '../../../helpers/logger' 9import { 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 })