]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/notifier.ts
Transcode HLS playlists in a tmp directory
[github/Chocobozzz/PeerTube.git] / server / lib / notifier.ts
index 9c2f16c2768c68127f7b733635363ca861b8f501..740c274d72116cd1b4edf0c310bffffbb03c8be6 100644 (file)
@@ -1,4 +1,4 @@
-import { AbuseMessageModel } from '@server/models/abuse/abuse-message'
+import { AccountModel } from '@server/models/account/account'
 import { getServerActor } from '@server/models/application/application'
 import { ServerBlocklistModel } from '@server/models/server/server-blocklist'
 import {
@@ -24,7 +24,6 @@ import { MCommentOwnerVideo, MVideoAccountLight, MVideoFullLight } from '../type
 import { isBlockedByServerOrAccount } from './blocklist'
 import { Emailer } from './emailer'
 import { PeerTubeSocket } from './peertube-socket'
-import { AccountModel } from '@server/models/account/account'
 
 class Notifier {
 
@@ -464,11 +463,11 @@ class Notifier {
 
     async function buildReporterOptions () {
       // Only notify our users
-      if (abuse.ReporterAccount.isOwned() !== true) return
+      if (abuse.ReporterAccount.isOwned() !== true) return undefined
 
       const reporter = await UserModel.loadByAccountActorId(abuse.ReporterAccount.actorId)
       // Don't notify my own message
-      if (reporter.Account.id === message.accountId) return
+      if (reporter.Account.id === message.accountId) return undefined
 
       return { users: [ reporter ], settingGetter, notificationCreator, emailSender: emailSenderReporter }
     }
@@ -478,20 +477,21 @@ class Notifier {
       // Don't notify my own message
       moderators = moderators.filter(m => m.Account.id !== message.accountId)
 
-      if (moderators.length === 0) return
+      if (moderators.length === 0) return undefined
 
       return { users: moderators, settingGetter, notificationCreator, emailSender: emailSenderModerators }
     }
 
-    const [ reporterOptions, moderatorsOptions ] = await Promise.all([
+    const options = await Promise.all([
       buildReporterOptions(),
       buildModeratorsOptions()
     ])
 
-    return Promise.all([
-      this.notify(reporterOptions),
-      this.notify(moderatorsOptions)
-    ])
+    return Promise.all(
+      options
+        .filter(opt => !!opt)
+        .map(opt => this.notify(opt))
+    )
   }
 
   private async notifyModeratorsOfVideoAutoBlacklist (videoBlacklist: MVideoBlacklistLightVideo) {