aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/shared/video/video-edit.model.ts4
-rw-r--r--client/src/app/shared/video/video.service.ts3
-rw-r--r--server/controllers/api/videos/index.ts4
-rw-r--r--server/middlewares/validators/videos.ts6
-rw-r--r--server/models/video/schedule-video-update.ts11
5 files changed, 25 insertions, 3 deletions
diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts
index 78aed4f9f..8562f8d25 100644
--- a/client/src/app/shared/video/video-edit.model.ts
+++ b/client/src/app/shared/video/video-edit.model.ts
@@ -55,7 +55,7 @@ export class VideoEdit implements VideoUpdate {
55 }) 55 })
56 56
57 // If schedule publication, the video is private and will be changed to public privacy 57 // If schedule publication, the video is private and will be changed to public privacy
58 if (values['schedulePublicationAt']) { 58 if (parseInt(values['privacy'], 10) === VideoEdit.SPECIAL_SCHEDULED_PRIVACY) {
59 const updateAt = (values['schedulePublicationAt'] as Date) 59 const updateAt = (values['schedulePublicationAt'] as Date)
60 updateAt.setSeconds(0) 60 updateAt.setSeconds(0)
61 61
@@ -64,6 +64,8 @@ export class VideoEdit implements VideoUpdate {
64 updateAt: updateAt.toISOString(), 64 updateAt: updateAt.toISOString(),
65 privacy: VideoPrivacy.PUBLIC 65 privacy: VideoPrivacy.PUBLIC
66 } 66 }
67 } else {
68 this.scheduleUpdate = null
67 } 69 }
68 } 70 }
69 71
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index 3af90e7ad..2da36ff1b 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -68,6 +68,7 @@ export class VideoService {
68 const category = video.category || null 68 const category = video.category || null
69 const description = video.description || null 69 const description = video.description || null
70 const support = video.support || null 70 const support = video.support || null
71 const scheduleUpdate = video.scheduleUpdate || null
71 72
72 const body: VideoUpdate = { 73 const body: VideoUpdate = {
73 name: video.name, 74 name: video.name,
@@ -84,7 +85,7 @@ export class VideoService {
84 commentsEnabled: video.commentsEnabled, 85 commentsEnabled: video.commentsEnabled,
85 thumbnailfile: video.thumbnailfile, 86 thumbnailfile: video.thumbnailfile,
86 previewfile: video.previewfile, 87 previewfile: video.previewfile,
87 scheduleUpdate: video.scheduleUpdate || undefined 88 scheduleUpdate
88 } 89 }
89 90
90 const data = objectToFormData(body) 91 const data = objectToFormData(body)
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 79ca4699f..ca800a9a8 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -342,10 +342,12 @@ async function updateVideo (req: express.Request, res: express.Response) {
342 updateAt: videoInfoToUpdate.scheduleUpdate.updateAt, 342 updateAt: videoInfoToUpdate.scheduleUpdate.updateAt,
343 privacy: videoInfoToUpdate.scheduleUpdate.privacy || null 343 privacy: videoInfoToUpdate.scheduleUpdate.privacy || null
344 }, { transaction: t }) 344 }, { transaction: t })
345 } else if (videoInfoToUpdate.scheduleUpdate === null) {
346 await ScheduleVideoUpdateModel.deleteByVideoId(videoInstanceUpdated.id, t)
345 } 347 }
346 348
347 const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE 349 const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE
348 await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo) 350 await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t)
349 }) 351 })
350 352
351 logger.info('Video with name %s and uuid %s updated.', videoInstance.name, videoInstance.uuid) 353 logger.info('Video with name %s and uuid %s updated.', videoInstance.name, videoInstance.uuid)
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts
index da17b4a68..5595edf17 100644
--- a/server/middlewares/validators/videos.ts
+++ b/server/middlewares/validators/videos.ts
@@ -94,6 +94,9 @@ const videosAddValidator = [
94 body('channelId') 94 body('channelId')
95 .toInt() 95 .toInt()
96 .custom(isIdValid).withMessage('Should have correct video channel id'), 96 .custom(isIdValid).withMessage('Should have correct video channel id'),
97 body('scheduleUpdate')
98 .optional()
99 .customSanitizer(toValueOrNull),
97 body('scheduleUpdate.updateAt') 100 body('scheduleUpdate.updateAt')
98 .optional() 101 .optional()
99 .custom(isDateValid).withMessage('Should have a valid schedule update date'), 102 .custom(isDateValid).withMessage('Should have a valid schedule update date'),
@@ -199,6 +202,9 @@ const videosUpdateValidator = [
199 .optional() 202 .optional()
200 .toInt() 203 .toInt()
201 .custom(isIdValid).withMessage('Should have correct video channel id'), 204 .custom(isIdValid).withMessage('Should have correct video channel id'),
205 body('scheduleUpdate')
206 .optional()
207 .customSanitizer(toValueOrNull),
202 body('scheduleUpdate.updateAt') 208 body('scheduleUpdate.updateAt')
203 .optional() 209 .optional()
204 .custom(isDateValid).withMessage('Should have a valid schedule update date'), 210 .custom(isDateValid).withMessage('Should have a valid schedule update date'),
diff --git a/server/models/video/schedule-video-update.ts b/server/models/video/schedule-video-update.ts
index 3cf5f6c99..1e56562e1 100644
--- a/server/models/video/schedule-video-update.ts
+++ b/server/models/video/schedule-video-update.ts
@@ -83,6 +83,17 @@ export class ScheduleVideoUpdateModel extends Model<ScheduleVideoUpdateModel> {
83 return ScheduleVideoUpdateModel.findAll(query) 83 return ScheduleVideoUpdateModel.findAll(query)
84 } 84 }
85 85
86 static deleteByVideoId (videoId: number, t: Transaction) {
87 const query = {
88 where: {
89 videoId
90 },
91 transaction: t
92 }
93
94 return ScheduleVideoUpdateModel.destroy(query)
95 }
96
86 toFormattedJSON () { 97 toFormattedJSON () {
87 return { 98 return {
88 updateAt: this.updateAt, 99 updateAt: this.updateAt,