aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/notifier/notifier.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/notifier/notifier.ts')
-rw-r--r--server/lib/notifier/notifier.ts15
1 files changed, 11 insertions, 4 deletions
diff --git a/server/lib/notifier/notifier.ts b/server/lib/notifier/notifier.ts
index a6f13780b..d1c4c0215 100644
--- a/server/lib/notifier/notifier.ts
+++ b/server/lib/notifier/notifier.ts
@@ -7,12 +7,12 @@ import { MAbuseFull, MAbuseMessage, MActorFollowFull, MApplication, MPlugin } fr
7import { MCommentOwnerVideo, MVideoAccountLight, MVideoFullLight } from '../../types/models/video' 7import { MCommentOwnerVideo, MVideoAccountLight, MVideoFullLight } from '../../types/models/video'
8import { JobQueue } from '../job-queue' 8import { JobQueue } from '../job-queue'
9import { PeerTubeSocket } from '../peertube-socket' 9import { PeerTubeSocket } from '../peertube-socket'
10import { Hooks } from '../plugins/hooks'
10import { 11import {
11 AbstractNotification, 12 AbstractNotification,
12 AbuseStateChangeForReporter, 13 AbuseStateChangeForReporter,
13 AutoFollowForInstance, 14 AutoFollowForInstance,
14 CommentMention, 15 CommentMention,
15 StudioEditionFinishedForOwner,
16 FollowForInstance, 16 FollowForInstance,
17 FollowForUser, 17 FollowForUser,
18 ImportFinishedForOwner, 18 ImportFinishedForOwner,
@@ -31,6 +31,7 @@ import {
31 OwnedPublicationAfterScheduleUpdate, 31 OwnedPublicationAfterScheduleUpdate,
32 OwnedPublicationAfterTranscoding, 32 OwnedPublicationAfterTranscoding,
33 RegistrationForModerators, 33 RegistrationForModerators,
34 StudioEditionFinishedForOwner,
34 UnblacklistForOwner 35 UnblacklistForOwner
35} from './shared' 36} from './shared'
36 37
@@ -222,15 +223,21 @@ class Notifier {
222 for (const user of users) { 223 for (const user of users) {
223 const setting = object.getSetting(user) 224 const setting = object.getSetting(user)
224 225
225 if (this.isWebNotificationEnabled(setting)) { 226 const webNotificationEnabled = this.isWebNotificationEnabled(setting)
226 const notification = await object.createNotification(user) 227 const emailNotificationEnabled = this.isEmailEnabled(user, setting)
228 const notification = object.createNotification(user)
229
230 if (webNotificationEnabled) {
231 await notification.save()
227 232
228 PeerTubeSocket.Instance.sendNotification(user.id, notification) 233 PeerTubeSocket.Instance.sendNotification(user.id, notification)
229 } 234 }
230 235
231 if (this.isEmailEnabled(user, setting)) { 236 if (emailNotificationEnabled) {
232 toEmails.push(user.email) 237 toEmails.push(user.email)
233 } 238 }
239
240 Hooks.runAction('action:notifier.notification.created', { webNotificationEnabled, emailNotificationEnabled, user, notification })
234 } 241 }
235 242
236 for (const to of toEmails) { 243 for (const to of toEmails) {