diff options
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/index.ts | 20 |
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' | |||
52 | import { VideoFilter } from '../../../../shared/models/videos/video-query.type' | 52 | import { VideoFilter } from '../../../../shared/models/videos/video-query.type' |
53 | import { VideoSortField } from '../../../../client/src/app/shared/video/sort-field.type' | 53 | import { VideoSortField } from '../../../../client/src/app/shared/video/sort-field.type' |
54 | import { createReqFiles, isNSFWHidden } from '../../../helpers/express-utils' | 54 | import { createReqFiles, isNSFWHidden } from '../../../helpers/express-utils' |
55 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' | ||
55 | 56 | ||
56 | const videosRouter = express.Router() | 57 | const 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 | }) |