]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/process/process-flag.ts
Fix embed url
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / process / process-flag.ts
index 8d1c9c869e9bb2272e8983ac97fa1aaf0d5daee2..1d7132a3a7010f8a04ac94747ae12af42e20070f 100644 (file)
@@ -1,4 +1,9 @@
-import { ActivityCreate, ActivityFlag, VideoAbuseState } from '../../../../shared'
+import {
+  ActivityCreate,
+  ActivityFlag,
+  VideoAbuseState,
+  videoAbusePredefinedReasonsMap
+} from '../../../../shared'
 import { VideoAbuseObject } from '../../../../shared/models/activitypub/objects'
 import { retryTransactionWrapper } from '../../../helpers/database-utils'
 import { logger } from '../../../helpers/logger'
@@ -38,13 +43,21 @@ async function processCreateVideoAbuse (activity: ActivityCreate | ActivityFlag,
 
       const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: object })
       const reporterAccount = await sequelizeTypescript.transaction(async t => AccountModel.load(account.id, t))
+      const tags = Array.isArray(flag.tag) ? flag.tag : []
+      const predefinedReasons = tags.map(tag => videoAbusePredefinedReasonsMap[tag.name])
+                                    .filter(v => !isNaN(v))
+      const startAt = flag.startAt
+      const endAt = flag.endAt
 
       const videoAbuseInstance = await sequelizeTypescript.transaction(async t => {
         const videoAbuseData = {
           reporterAccountId: account.id,
           reason: flag.content,
           videoId: video.id,
-          state: VideoAbuseState.PENDING
+          state: VideoAbuseState.PENDING,
+          predefinedReasons,
+          startAt,
+          endAt
         }
 
         const videoAbuseInstance: MVideoAbuseAccountVideo = await VideoAbuseModel.create(videoAbuseData, { transaction: t })