]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/notifier/shared/video-publication/studio-edition-finished-for-owner.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / server / lib / notifier / shared / video-publication / studio-edition-finished-for-owner.ts
CommitLineData
1808a1f8
C
1import { logger } from '@server/helpers/logger'
2import { WEBSERVER } from '@server/initializers/constants'
3import { UserModel } from '@server/models/user/user'
4import { UserNotificationModel } from '@server/models/user/user-notification'
5import { MUserDefault, MUserWithNotificationSetting, MVideoFullLight, UserNotificationModelForApi } from '@server/types/models'
6import { UserNotificationType } from '@shared/models'
7import { AbstractNotification } from '../common/abstract-notification'
8
92e66e04 9export class StudioEditionFinishedForOwner extends AbstractNotification <MVideoFullLight> {
1808a1f8
C
10 private user: MUserDefault
11
12 async prepare () {
13 this.user = await UserModel.loadByVideoId(this.payload.id)
14 }
15
16 log () {
92e66e04 17 logger.info('Notifying user %s its video studio edition %s is finished.', this.user.username, this.payload.url)
1808a1f8
C
18 }
19
20 getSetting (user: MUserWithNotificationSetting) {
92e66e04 21 return user.NotificationSetting.myVideoStudioEditionFinished
1808a1f8
C
22 }
23
24 getTargetUsers () {
25 if (!this.user) return []
26
27 return [ this.user ]
28 }
29
785f1897
C
30 createNotification (user: MUserWithNotificationSetting) {
31 const notification = UserNotificationModel.build<UserNotificationModelForApi>({
92e66e04 32 type: UserNotificationType.MY_VIDEO_STUDIO_EDITION_FINISHED,
1808a1f8
C
33 userId: user.id,
34 videoId: this.payload.id
35 })
36 notification.Video = this.payload
37
38 return notification
39 }
40
41 createEmail (to: string) {
42 const videoUrl = WEBSERVER.URL + this.payload.getWatchStaticPath()
43
44 return {
45 to,
46 subject: `Edition of your video ${this.payload.name} has finished`,
47 text: `Edition of your video ${this.payload.name} has finished.`,
48 locals: {
49 title: 'Video edition has finished',
50 action: {
51 text: 'View video',
52 url: videoUrl
53 }
54 }
55 }
56 }
57}