1 import { logger } from '@server/helpers/logger'
2 import { WEBSERVER } from '@server/initializers/constants'
3 import { UserModel } from '@server/models/user/user'
4 import { UserNotificationModel } from '@server/models/user/user-notification'
5 import { MUserDefault, MUserWithNotificationSetting, MVideoFullLight, UserNotificationModelForApi } from '@server/types/models'
6 import { UserNotificationType } from '@shared/models'
7 import { AbstractNotification } from '../common/abstract-notification'
9 export class StudioEditionFinishedForOwner extends AbstractNotification <MVideoFullLight> {
10 private user: MUserDefault
13 this.user = await UserModel.loadByVideoId(this.payload.id)
17 logger.info('Notifying user %s its video studio edition %s is finished.', this.user.username, this.payload.url)
20 getSetting (user: MUserWithNotificationSetting) {
21 return user.NotificationSetting.myVideoStudioEditionFinished
25 if (!this.user) return []
30 async createNotification (user: MUserWithNotificationSetting) {
31 const notification = await UserNotificationModel.create<UserNotificationModelForApi>({
32 type: UserNotificationType.MY_VIDEO_STUDIO_EDITION_FINISHED,
34 videoId: this.payload.id
36 notification.Video = this.payload
41 createEmail (to: string) {
42 const videoUrl = WEBSERVER.URL + this.payload.getWatchStaticPath()
46 subject: `Edition of your video ${this.payload.name} has finished`,
47 text: `Edition of your video ${this.payload.name} has finished.`,
49 title: 'Video edition has finished',