mirror of https://github.com/Chocobozzz/PeerTube
Fix removing scheduled update
parent
fc11a44ec9
commit
e94fc29706
|
@ -55,7 +55,7 @@ export class VideoEdit implements VideoUpdate {
|
|||
})
|
||||
|
||||
// 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)
|
||||
|
||||
|
@ -64,6 +64,8 @@ export class VideoEdit implements VideoUpdate {
|
|||
updateAt: updateAt.toISOString(),
|
||||
privacy: VideoPrivacy.PUBLIC
|
||||
}
|
||||
} else {
|
||||
this.scheduleUpdate = null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ export class VideoService {
|
|||
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,
|
||||
|
@ -84,7 +85,7 @@ export class VideoService {
|
|||
commentsEnabled: video.commentsEnabled,
|
||||
thumbnailfile: video.thumbnailfile,
|
||||
previewfile: video.previewfile,
|
||||
scheduleUpdate: video.scheduleUpdate || undefined
|
||||
scheduleUpdate
|
||||
}
|
||||
|
||||
const data = objectToFormData(body)
|
||||
|
|
|
@ -342,10 +342,12 @@ async function updateVideo (req: express.Request, res: express.Response) {
|
|||
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)
|
||||
|
|
|
@ -94,6 +94,9 @@ const videosAddValidator = [
|
|||
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'),
|
||||
|
@ -199,6 +202,9 @@ const videosUpdateValidator = [
|
|||
.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'),
|
||||
|
|
|
@ -83,6 +83,17 @@ export class ScheduleVideoUpdateModel extends Model<ScheduleVideoUpdateModel> {
|
|||
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,
|
||||
|
|
Loading…
Reference in New Issue