diff options
Diffstat (limited to 'server/lib/notifier.ts')
-rw-r--r-- | server/lib/notifier.ts | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/server/lib/notifier.ts b/server/lib/notifier.ts index 710c2d30f..017739523 100644 --- a/server/lib/notifier.ts +++ b/server/lib/notifier.ts | |||
@@ -5,7 +5,7 @@ import { UserNotificationModel } from '../models/account/user-notification' | |||
5 | import { UserModel } from '../models/account/user' | 5 | import { UserModel } from '../models/account/user' |
6 | import { PeerTubeSocket } from './peertube-socket' | 6 | import { PeerTubeSocket } from './peertube-socket' |
7 | import { CONFIG } from '../initializers/config' | 7 | import { CONFIG } from '../initializers/config' |
8 | import { VideoPrivacy, VideoState } from '../../shared/models/videos' | 8 | import { VideoPrivacy, VideoState, VideoAbuse } from '../../shared/models/videos' |
9 | import { AccountBlocklistModel } from '../models/account/account-blocklist' | 9 | import { AccountBlocklistModel } from '../models/account/account-blocklist' |
10 | import { | 10 | import { |
11 | MCommentOwnerVideo, | 11 | MCommentOwnerVideo, |
@@ -77,9 +77,9 @@ class Notifier { | |||
77 | .catch(err => logger.error('Cannot notify mentions of comment %s.', comment.url, { err })) | 77 | .catch(err => logger.error('Cannot notify mentions of comment %s.', comment.url, { err })) |
78 | } | 78 | } |
79 | 79 | ||
80 | notifyOnNewVideoAbuse (videoAbuse: MVideoAbuseVideo): void { | 80 | notifyOnNewVideoAbuse (parameters: { videoAbuse: VideoAbuse, videoAbuseInstance: MVideoAbuseVideo, reporter: string }): void { |
81 | this.notifyModeratorsOfNewVideoAbuse(videoAbuse) | 81 | this.notifyModeratorsOfNewVideoAbuse(parameters) |
82 | .catch(err => logger.error('Cannot notify of new video abuse of video %s.', videoAbuse.Video.url, { err })) | 82 | .catch(err => logger.error('Cannot notify of new video abuse of video %s.', parameters.videoAbuseInstance.Video.url, { err })) |
83 | } | 83 | } |
84 | 84 | ||
85 | notifyOnVideoAutoBlacklist (videoBlacklist: MVideoBlacklistLightVideo): void { | 85 | notifyOnVideoAutoBlacklist (videoBlacklist: MVideoBlacklistLightVideo): void { |
@@ -350,11 +350,15 @@ class Notifier { | |||
350 | return this.notify({ users: admins, settingGetter, notificationCreator, emailSender }) | 350 | return this.notify({ users: admins, settingGetter, notificationCreator, emailSender }) |
351 | } | 351 | } |
352 | 352 | ||
353 | private async notifyModeratorsOfNewVideoAbuse (videoAbuse: MVideoAbuseVideo) { | 353 | private async notifyModeratorsOfNewVideoAbuse (parameters: { |
354 | videoAbuse: VideoAbuse | ||
355 | videoAbuseInstance: MVideoAbuseVideo | ||
356 | reporter: string | ||
357 | }) { | ||
354 | const moderators = await UserModel.listWithRight(UserRight.MANAGE_VIDEO_ABUSES) | 358 | const moderators = await UserModel.listWithRight(UserRight.MANAGE_VIDEO_ABUSES) |
355 | if (moderators.length === 0) return | 359 | if (moderators.length === 0) return |
356 | 360 | ||
357 | logger.info('Notifying %s user/moderators of new video abuse %s.', moderators.length, videoAbuse.Video.url) | 361 | logger.info('Notifying %s user/moderators of new video abuse %s.', moderators.length, parameters.videoAbuseInstance.Video.url) |
358 | 362 | ||
359 | function settingGetter (user: MUserWithNotificationSetting) { | 363 | function settingGetter (user: MUserWithNotificationSetting) { |
360 | return user.NotificationSetting.videoAbuseAsModerator | 364 | return user.NotificationSetting.videoAbuseAsModerator |
@@ -364,15 +368,15 @@ class Notifier { | |||
364 | const notification: UserNotificationModelForApi = await UserNotificationModel.create<UserNotificationModelForApi>({ | 368 | const notification: UserNotificationModelForApi = await UserNotificationModel.create<UserNotificationModelForApi>({ |
365 | type: UserNotificationType.NEW_VIDEO_ABUSE_FOR_MODERATORS, | 369 | type: UserNotificationType.NEW_VIDEO_ABUSE_FOR_MODERATORS, |
366 | userId: user.id, | 370 | userId: user.id, |
367 | videoAbuseId: videoAbuse.id | 371 | videoAbuseId: parameters.videoAbuse.id |
368 | }) | 372 | }) |
369 | notification.VideoAbuse = videoAbuse | 373 | notification.VideoAbuse = parameters.videoAbuseInstance |
370 | 374 | ||
371 | return notification | 375 | return notification |
372 | } | 376 | } |
373 | 377 | ||
374 | function emailSender (emails: string[]) { | 378 | function emailSender (emails: string[]) { |
375 | return Emailer.Instance.addVideoAbuseModeratorsNotification(emails, videoAbuse) | 379 | return Emailer.Instance.addVideoAbuseModeratorsNotification(emails, parameters) |
376 | } | 380 | } |
377 | 381 | ||
378 | return this.notify({ users: moderators, settingGetter, notificationCreator, emailSender }) | 382 | return this.notify({ users: moderators, settingGetter, notificationCreator, emailSender }) |