From a15871560f80e07386c1dabb8370cd2664ecfd1f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 31 Jan 2020 16:56:52 +0100 Subject: Move to eslint --- server/lib/notifier.ts | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'server/lib/notifier.ts') diff --git a/server/lib/notifier.ts b/server/lib/notifier.ts index 679b9bcf6..63197eee1 100644 --- a/server/lib/notifier.ts +++ b/server/lib/notifier.ts @@ -6,7 +6,6 @@ import { UserModel } from '../models/account/user' import { PeerTubeSocket } from './peertube-socket' import { CONFIG } from '../initializers/config' import { VideoPrivacy, VideoState } from '../../shared/models/videos' -import * as Bluebird from 'bluebird' import { AccountBlocklistModel } from '../models/account/account-blocklist' import { MCommentOwnerVideo, @@ -17,7 +16,8 @@ import { MVideoFullLight } from '../typings/models/video' import { - MUser, MUserAccount, + MUser, + MUserAccount, MUserDefault, MUserNotifSettingAccount, MUserWithNotificationSetting, @@ -32,14 +32,15 @@ class Notifier { private static instance: Notifier - private constructor () {} + private constructor () { + } notifyOnNewVideoIfNeeded (video: MVideoAccountLight): void { // Only notify on public and published videos which are not blacklisted if (video.privacy !== VideoPrivacy.PUBLIC || video.state !== VideoState.PUBLISHED || video.isBlacklisted()) return this.notifySubscribersOfNewVideo(video) - .catch(err => logger.error('Cannot notify subscribers of new video %s.', video.url, { err })) + .catch(err => logger.error('Cannot notify subscribers of new video %s.', video.url, { err })) } notifyOnVideoPublishedAfterTranscoding (video: MVideoFullLight): void { @@ -63,7 +64,9 @@ class Notifier { if (video.ScheduleVideoUpdate || (video.waitTranscoding && video.state !== VideoState.PUBLISHED)) return this.notifyOwnedVideoHasBeenPublished(video) - .catch(err => logger.error('Cannot notify owner that its video %s has been published after removed from auto-blacklist.', video.url, { err })) // tslint:disable-line:max-line-length + .catch(err => { + logger.error('Cannot notify owner that its video %s has been published after removed from auto-blacklist.', video.url, { err }) + }) } notifyOnNewComment (comment: MCommentOwnerVideo): void { @@ -76,17 +79,17 @@ class Notifier { notifyOnNewVideoAbuse (videoAbuse: MVideoAbuseVideo): void { this.notifyModeratorsOfNewVideoAbuse(videoAbuse) - .catch(err => logger.error('Cannot notify of new video abuse of video %s.', videoAbuse.Video.url, { err })) + .catch(err => logger.error('Cannot notify of new video abuse of video %s.', videoAbuse.Video.url, { err })) } notifyOnVideoAutoBlacklist (videoBlacklist: MVideoBlacklistLightVideo): void { this.notifyModeratorsOfVideoAutoBlacklist(videoBlacklist) - .catch(err => logger.error('Cannot notify of auto-blacklist of video %s.', videoBlacklist.Video.url, { err })) + .catch(err => logger.error('Cannot notify of auto-blacklist of video %s.', videoBlacklist.Video.url, { err })) } notifyOnVideoBlacklist (videoBlacklist: MVideoBlacklistVideo): void { this.notifyVideoOwnerOfBlacklist(videoBlacklist) - .catch(err => logger.error('Cannot notify video owner of new video blacklist of %s.', videoBlacklist.Video.url, { err })) + .catch(err => logger.error('Cannot notify video owner of new video blacklist of %s.', videoBlacklist.Video.url, { err })) } notifyOnVideoUnblacklist (video: MVideoFullLight): void { @@ -96,7 +99,7 @@ class Notifier { notifyOnFinishedVideoImport (videoImport: MVideoImportVideo, success: boolean): void { this.notifyOwnerVideoImportIsFinished(videoImport, success) - .catch(err => logger.error('Cannot notify owner that its video import %s is finished.', videoImport.getTargetIdentifier(), { err })) + .catch(err => logger.error('Cannot notify owner that its video import %s is finished.', videoImport.getTargetIdentifier(), { err })) } notifyOnNewUserRegistration (user: MUserDefault): void { @@ -106,14 +109,14 @@ class Notifier { notifyOfNewUserFollow (actorFollow: MActorFollowFull): void { this.notifyUserOfNewActorFollow(actorFollow) - .catch(err => { - logger.error( - 'Cannot notify owner of channel %s of a new follow by %s.', - actorFollow.ActorFollowing.VideoChannel.getDisplayName(), - actorFollow.ActorFollower.Account.getDisplayName(), - { err } - ) - }) + .catch(err => { + logger.error( + 'Cannot notify owner of channel %s of a new follow by %s.', + actorFollow.ActorFollowing.VideoChannel.getDisplayName(), + actorFollow.ActorFollower.Account.getDisplayName(), + { err } + ) + }) } notifyOfNewInstanceFollow (actorFollow: MActorFollowFull): void { @@ -548,10 +551,10 @@ class Notifier { return this.notify({ users: moderators, settingGetter, notificationCreator, emailSender }) } - private async notify (options: { - users: T[], - notificationCreator: (user: T) => Promise, - emailSender: (emails: string[]) => Promise | Bluebird, + private async notify (options: { + users: T[] + notificationCreator: (user: T) => Promise + emailSender: (emails: string[]) => void settingGetter: (user: T) => UserNotificationSettingValue }) { const emails: string[] = [] @@ -569,7 +572,7 @@ class Notifier { } if (emails.length !== 0) { - await options.emailSender(emails) + options.emailSender(emails) } } -- cgit v1.2.3