aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/users.ts6
-rw-r--r--server/controllers/api/videos/index.ts20
2 files changed, 25 insertions, 1 deletions
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts
index 0aeb77964..891056912 100644
--- a/server/controllers/api/users.ts
+++ b/server/controllers/api/users.ts
@@ -174,7 +174,11 @@ async function getUserVideos (req: express.Request, res: express.Response, next:
174 false // Display my NSFW videos 174 false // Display my NSFW videos
175 ) 175 )
176 176
177 const additionalAttributes = { waitTranscoding: true, state: true } 177 const additionalAttributes = {
178 waitTranscoding: true,
179 state: true,
180 scheduledUpdate: true
181 }
178 return res.json(getFormattedObjects(resultList.data, resultList.total, { additionalAttributes })) 182 return res.json(getFormattedObjects(resultList.data, resultList.total, { additionalAttributes }))
179} 183}
180 184
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 })