aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-14 18:06:56 +0200
committerChocobozzz <me@florianbigard.com>2018-06-14 18:06:56 +0200
commit2baea0c77cc765f7cbca9c9a2f4272268892a35c (patch)
tree47b1be5535439409a97eb80c0222c9c821b83dae /server/controllers/api/videos
parentbf079b7bfd7f0fb75ceb28e333bb4b74d8840dd4 (diff)
downloadPeerTube-2baea0c77cc765f7cbca9c9a2f4272268892a35c.tar.gz
PeerTube-2baea0c77cc765f7cbca9c9a2f4272268892a35c.tar.zst
PeerTube-2baea0c77cc765f7cbca9c9a2f4272268892a35c.zip
Add ability for uploaders to schedule video update
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r--server/controllers/api/videos/index.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 78963d89b..79ca4699f 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -52,6 +52,7 @@ import { rateVideoRouter } from './rate'
52import { VideoFilter } from '../../../../shared/models/videos/video-query.type' 52import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
53import { VideoSortField } from '../../../../client/src/app/shared/video/sort-field.type' 53import { VideoSortField } from '../../../../client/src/app/shared/video/sort-field.type'
54import { createReqFiles, isNSFWHidden } from '../../../helpers/express-utils' 54import { createReqFiles, isNSFWHidden } from '../../../helpers/express-utils'
55import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
55 56
56const videosRouter = express.Router() 57const videosRouter = express.Router()
57 58
@@ -231,6 +232,7 @@ async function addVideo (req: express.Request, res: express.Response) {
231 232
232 video.VideoFiles = [ videoFile ] 233 video.VideoFiles = [ videoFile ]
233 234
235 // Create tags
234 if (videoInfo.tags !== undefined) { 236 if (videoInfo.tags !== undefined) {
235 const tagInstances = await TagModel.findOrCreateTags(videoInfo.tags, t) 237 const tagInstances = await TagModel.findOrCreateTags(videoInfo.tags, t)
236 238
@@ -238,6 +240,15 @@ async function addVideo (req: express.Request, res: express.Response) {
238 video.Tags = tagInstances 240 video.Tags = tagInstances
239 } 241 }
240 242
243 // Schedule an update in the future?
244 if (videoInfo.scheduleUpdate) {
245 await ScheduleVideoUpdateModel.create({
246 videoId: video.id,
247 updateAt: videoInfo.scheduleUpdate.updateAt,
248 privacy: videoInfo.scheduleUpdate.privacy || null
249 }, { transaction: t })
250 }
251
241 await federateVideoIfNeeded(video, true, t) 252 await federateVideoIfNeeded(video, true, t)
242 253
243 logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid) 254 logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid)
@@ -324,6 +335,15 @@ async function updateVideo (req: express.Request, res: express.Response) {
324 if (wasPrivateVideo === false) await changeVideoChannelShare(videoInstanceUpdated, oldVideoChannel, t) 335 if (wasPrivateVideo === false) await changeVideoChannelShare(videoInstanceUpdated, oldVideoChannel, t)
325 } 336 }
326 337
338 // Schedule an update in the future?
339 if (videoInfoToUpdate.scheduleUpdate) {
340 await ScheduleVideoUpdateModel.upsert({
341 videoId: videoInstanceUpdated.id,
342 updateAt: videoInfoToUpdate.scheduleUpdate.updateAt,
343 privacy: videoInfoToUpdate.scheduleUpdate.privacy || null
344 }, { transaction: t })
345 }
346
327 const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE 347 const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE
328 await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo) 348 await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo)
329 }) 349 })