1 import { VideoPrivacy } from '../../../../../shared/models/videos/video-privacy.enum'
2 import { VideoUpdate } from '../../../../../shared/models/videos'
3 import { VideoScheduleUpdate } from '../../../../../shared/models/videos/video-schedule-update.model'
4 import { Video } from '../../../../../shared/models/videos/video.model'
6 export class VideoEdit implements VideoUpdate {
7 static readonly SPECIAL_SCHEDULED_PRIVACY = -1
16 commentsEnabled: boolean
17 downloadEnabled: boolean
18 waitTranscoding: boolean
28 scheduleUpdate?: VideoScheduleUpdate
33 commentsEnabled: boolean,
34 downloadEnabled: boolean,
41 this.uuid = video.uuid
42 this.category = video.category.id
43 this.licence = video.licence.id
44 this.language = video.language.id
45 this.description = video.description
46 this.name = video.name
47 this.tags = video.tags
48 this.nsfw = video.nsfw
49 this.commentsEnabled = video.commentsEnabled
50 this.downloadEnabled = video.downloadEnabled
51 this.waitTranscoding = video.waitTranscoding
52 this.channelId = video.channel.id
53 this.privacy = video.privacy.id
54 this.support = video.support
55 this.thumbnailUrl = video.thumbnailUrl
56 this.previewUrl = video.previewUrl
58 this.scheduleUpdate = video.scheduledUpdate
62 patch (values: { [ id: string ]: string }) {
63 Object.keys(values).forEach((key) => {
64 this[ key ] = values[ key ]
67 // If schedule publication, the video is private and will be changed to public privacy
68 if (parseInt(values['privacy'], 10) === VideoEdit.SPECIAL_SCHEDULED_PRIVACY) {
69 const updateAt = new Date(values['schedulePublicationAt'])
70 updateAt.setSeconds(0)
72 this.privacy = VideoPrivacy.PRIVATE
73 this.scheduleUpdate = {
74 updateAt: updateAt.toISOString(),
75 privacy: VideoPrivacy.PUBLIC
78 this.scheduleUpdate = null
84 category: this.category,
85 licence: this.licence,
86 language: this.language,
87 description: this.description,
88 support: this.support,
92 commentsEnabled: this.commentsEnabled,
93 downloadEnabled: this.downloadEnabled,
94 waitTranscoding: this.waitTranscoding,
95 channelId: this.channelId,
99 // Special case if we scheduled an update
100 if (this.scheduleUpdate) {
101 Object.assign(json, {
102 privacy: VideoEdit.SPECIAL_SCHEDULED_PRIVACY,
103 schedulePublicationAt: new Date(this.scheduleUpdate.updateAt.toString())