})
// If schedule publication, the video is private and will be changed to public privacy
- if (values['schedulePublicationAt']) {
+ if (parseInt(values['privacy'], 10) === VideoEdit.SPECIAL_SCHEDULED_PRIVACY) {
const updateAt = (values['schedulePublicationAt'] as Date)
updateAt.setSeconds(0)
updateAt: updateAt.toISOString(),
privacy: VideoPrivacy.PUBLIC
}
+ } else {
+ this.scheduleUpdate = null
}
}
const category = video.category || null
const description = video.description || null
const support = video.support || null
+ const scheduleUpdate = video.scheduleUpdate || null
const body: VideoUpdate = {
name: video.name,
commentsEnabled: video.commentsEnabled,
thumbnailfile: video.thumbnailfile,
previewfile: video.previewfile,
- scheduleUpdate: video.scheduleUpdate || undefined
+ scheduleUpdate
}
const data = objectToFormData(body)
updateAt: videoInfoToUpdate.scheduleUpdate.updateAt,
privacy: videoInfoToUpdate.scheduleUpdate.privacy || null
}, { transaction: t })
+ } else if (videoInfoToUpdate.scheduleUpdate === null) {
+ await ScheduleVideoUpdateModel.deleteByVideoId(videoInstanceUpdated.id, t)
}
const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE
- await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo)
+ await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t)
})
logger.info('Video with name %s and uuid %s updated.', videoInstance.name, videoInstance.uuid)
body('channelId')
.toInt()
.custom(isIdValid).withMessage('Should have correct video channel id'),
+ body('scheduleUpdate')
+ .optional()
+ .customSanitizer(toValueOrNull),
body('scheduleUpdate.updateAt')
.optional()
.custom(isDateValid).withMessage('Should have a valid schedule update date'),
.optional()
.toInt()
.custom(isIdValid).withMessage('Should have correct video channel id'),
+ body('scheduleUpdate')
+ .optional()
+ .customSanitizer(toValueOrNull),
body('scheduleUpdate.updateAt')
.optional()
.custom(isDateValid).withMessage('Should have a valid schedule update date'),
return ScheduleVideoUpdateModel.findAll(query)
}
+ static deleteByVideoId (videoId: number, t: Transaction) {
+ const query = {
+ where: {
+ videoId
+ },
+ transaction: t
+ }
+
+ return ScheduleVideoUpdateModel.destroy(query)
+ }
+
toFormattedJSON () {
return {
updateAt: this.updateAt,