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,
MVideoFullLight
} from '../typings/models/video'
import {
- MUser, MUserAccount,
+ MUser,
+ MUserAccount,
MUserDefault,
MUserNotifSettingAccount,
MUserWithNotificationSetting,
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 {
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 {
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 {
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 {
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 {
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 {
return this.notify({ users: moderators, settingGetter, notificationCreator, emailSender })
}
- private async notify <T extends MUserWithNotificationSetting> (options: {
- users: T[],
- notificationCreator: (user: T) => Promise<UserNotificationModelForApi>,
- emailSender: (emails: string[]) => Promise<any> | Bluebird<any>,
+ private async notify<T extends MUserWithNotificationSetting> (options: {
+ users: T[]
+ notificationCreator: (user: T) => Promise<UserNotificationModelForApi>
+ emailSender: (emails: string[]) => void
settingGetter: (user: T) => UserNotificationSettingValue
}) {
const emails: string[] = []
}
if (emails.length !== 0) {
- await options.emailSender(emails)
+ options.emailSender(emails)
}
}