X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fnotifier.ts;h=0177395239d6c77366b8eb65e50ffa68a9874294;hb=923ff87da2761fd88a8ca269ac1ef403abb583d2;hp=63197eee13deaa67e1594f6898824bffd2592b19;hpb=7cd1b12c19d0589d1d692ed0571ca0800f028aea;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/notifier.ts b/server/lib/notifier.ts index 63197eee1..017739523 100644 --- a/server/lib/notifier.ts +++ b/server/lib/notifier.ts @@ -5,7 +5,7 @@ import { UserNotificationModel } from '../models/account/user-notification' import { UserModel } from '../models/account/user' import { PeerTubeSocket } from './peertube-socket' import { CONFIG } from '../initializers/config' -import { VideoPrivacy, VideoState } from '../../shared/models/videos' +import { VideoPrivacy, VideoState, VideoAbuse } from '../../shared/models/videos' import { AccountBlocklistModel } from '../models/account/account-blocklist' import { MCommentOwnerVideo, @@ -26,7 +26,7 @@ import { import { MAccountDefault, MActorFollowFull } from '../typings/models' import { MVideoImportVideo } from '@server/typings/models/video/video-import' import { ServerBlocklistModel } from '@server/models/server/server-blocklist' -import { getServerActor } from '@server/helpers/utils' +import { getServerActor } from '@server/models/application/application' class Notifier { @@ -77,9 +77,9 @@ class Notifier { .catch(err => logger.error('Cannot notify mentions of comment %s.', comment.url, { err })) } - notifyOnNewVideoAbuse (videoAbuse: MVideoAbuseVideo): void { - this.notifyModeratorsOfNewVideoAbuse(videoAbuse) - .catch(err => logger.error('Cannot notify of new video abuse of video %s.', videoAbuse.Video.url, { err })) + notifyOnNewVideoAbuse (parameters: { videoAbuse: VideoAbuse, videoAbuseInstance: MVideoAbuseVideo, reporter: string }): void { + this.notifyModeratorsOfNewVideoAbuse(parameters) + .catch(err => logger.error('Cannot notify of new video abuse of video %s.', parameters.videoAbuseInstance.Video.url, { err })) } notifyOnVideoAutoBlacklist (videoBlacklist: MVideoBlacklistLightVideo): void { @@ -350,11 +350,15 @@ class Notifier { return this.notify({ users: admins, settingGetter, notificationCreator, emailSender }) } - private async notifyModeratorsOfNewVideoAbuse (videoAbuse: MVideoAbuseVideo) { + private async notifyModeratorsOfNewVideoAbuse (parameters: { + videoAbuse: VideoAbuse + videoAbuseInstance: MVideoAbuseVideo + reporter: string + }) { const moderators = await UserModel.listWithRight(UserRight.MANAGE_VIDEO_ABUSES) if (moderators.length === 0) return - logger.info('Notifying %s user/moderators of new video abuse %s.', moderators.length, videoAbuse.Video.url) + logger.info('Notifying %s user/moderators of new video abuse %s.', moderators.length, parameters.videoAbuseInstance.Video.url) function settingGetter (user: MUserWithNotificationSetting) { return user.NotificationSetting.videoAbuseAsModerator @@ -364,15 +368,15 @@ class Notifier { const notification: UserNotificationModelForApi = await UserNotificationModel.create({ type: UserNotificationType.NEW_VIDEO_ABUSE_FOR_MODERATORS, userId: user.id, - videoAbuseId: videoAbuse.id + videoAbuseId: parameters.videoAbuse.id }) - notification.VideoAbuse = videoAbuse + notification.VideoAbuse = parameters.videoAbuseInstance return notification } function emailSender (emails: string[]) { - return Emailer.Instance.addVideoAbuseModeratorsNotification(emails, videoAbuse) + return Emailer.Instance.addVideoAbuseModeratorsNotification(emails, parameters) } return this.notify({ users: moderators, settingGetter, notificationCreator, emailSender })