]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/process/process-flag.ts
Fix like/dislike federation
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / process / process-flag.ts
index 79ce6fb41e56e884cbdb5934a669dd3e25aa506e..8faab051eaf50c80991772d68707a717e566b6a0 100644 (file)
@@ -27,11 +27,11 @@ async function processCreateVideoAbuse (activity: ActivityCreate | ActivityFlag,
   logger.debug('Reporting remote abuse for video %s.', getAPId(flag.object))
 
   const account = byActor.Account
-  if (!account) throw new Error('Cannot create dislike with the non account actor ' + byActor.url)
+  if (!account) throw new Error('Cannot create video abuse with the non account actor ' + byActor.url)
 
   const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: flag.object })
 
-  return sequelizeTypescript.transaction(async t => {
+  const videoAbuse = await sequelizeTypescript.transaction(async t => {
     const videoAbuseData = {
       reporterAccountId: account.id,
       reason: flag.content,
@@ -42,8 +42,10 @@ async function processCreateVideoAbuse (activity: ActivityCreate | ActivityFlag,
     const videoAbuseInstance = await VideoAbuseModel.create(videoAbuseData, { transaction: t })
     videoAbuseInstance.Video = video
 
-    Notifier.Instance.notifyOnNewVideoAbuse(videoAbuseInstance)
-
     logger.info('Remote abuse for video uuid %s created', flag.object)
+
+    return videoAbuseInstance
   })
+
+  Notifier.Instance.notifyOnNewVideoAbuse(videoAbuse)
 }