]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/moderation.ts
Translated using Weblate (Kabyle)
[github/Chocobozzz/PeerTube.git] / server / lib / moderation.ts
index 4fc9cd747609a22d0d612caafc8e6c1fb944b566..5180b3299a21d95dfbce121103748530042d54ef 100644 (file)
@@ -18,9 +18,9 @@ import {
   MVideoAccountLightBlacklistAllFiles
 } from '@server/types/models'
 import { ActivityCreate } from '../../shared/models/activitypub'
-import { VideoTorrentObject } from '../../shared/models/activitypub/objects'
+import { VideoObject } from '../../shared/models/activitypub/objects'
 import { VideoCommentObject } from '../../shared/models/activitypub/objects/video-comment-object'
-import { VideoCreate, VideoImportCreate } from '../../shared/models/videos'
+import { LiveVideoCreate, VideoCreate, VideoImportCreate } from '../../shared/models/videos'
 import { VideoCommentCreate } from '../../shared/models/videos/video-comment.model'
 import { UserModel } from '../models/account/user'
 import { ActorModel } from '../models/activitypub/actor'
@@ -28,6 +28,7 @@ import { VideoModel } from '../models/video/video'
 import { VideoCommentModel } from '../models/video/video-comment'
 import { sendAbuse } from './activitypub/send/send-flag'
 import { Notifier } from './notifier'
+import { afterCommitIfTransaction } from '@server/helpers/database-utils'
 
 export type AcceptResult = {
   accepted: boolean
@@ -43,6 +44,13 @@ function isLocalVideoAccepted (object: {
   return { accepted: true }
 }
 
+function isLocalLiveVideoAccepted (object: {
+  liveVideoBody: LiveVideoCreate
+  user: UserModel
+}): AcceptResult {
+  return { accepted: true }
+}
+
 function isLocalVideoThreadAccepted (_object: {
   commentBody: VideoCommentCreate
   video: VideoModel
@@ -62,7 +70,7 @@ function isLocalVideoCommentReplyAccepted (_object: {
 
 function isRemoteVideoAccepted (_object: {
   activity: ActivityCreate
-  videoAP: VideoTorrentObject
+  videoAP: VideoObject
   byActor: ActorModel
 }): AcceptResult {
   return { accepted: true }
@@ -175,6 +183,8 @@ function createAccountAbuse (options: {
 }
 
 export {
+  isLocalLiveVideoAccepted,
+
   isLocalVideoAccepted,
   isLocalVideoThreadAccepted,
   isRemoteVideoAccepted,
@@ -213,13 +223,15 @@ async function createAbuse (options: {
     await sendAbuse(reporterAccount.Actor, abuseInstance, abuseInstance.FlaggedAccount, transaction)
   }
 
-  const abuseJSON = abuseInstance.toFormattedJSON()
+  const abuseJSON = abuseInstance.toFormattedAdminJSON()
   auditLogger.create(reporterAccount.Actor.getIdentifier(), new AbuseAuditView(abuseJSON))
 
-  Notifier.Instance.notifyOnNewAbuse({
-    abuse: abuseJSON,
-    abuseInstance,
-    reporter: reporterAccount.Actor.getIdentifier()
+  afterCommitIfTransaction(transaction, () => {
+    Notifier.Instance.notifyOnNewAbuse({
+      abuse: abuseJSON,
+      abuseInstance,
+      reporter: reporterAccount.Actor.getIdentifier()
+    })
   })
 
   logger.info('Abuse report %d created.', abuseInstance.id)