aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r--server/controllers/api/videos/index.ts24
1 files changed, 13 insertions, 11 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index c2fdb4f95..459795141 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -12,7 +12,7 @@ import {
12} from '../../../initializers' 12} from '../../../initializers'
13import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServerAndChannel } from '../../../lib/activitypub' 13import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServerAndChannel } from '../../../lib/activitypub'
14import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send' 14import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send'
15import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler' 15import { JobQueue } from '../../../lib/job-queue'
16import { 16import {
17 asyncMiddleware, authenticate, paginationValidator, setDefaultSort, setDefaultPagination, videosAddValidator, videosGetValidator, 17 asyncMiddleware, authenticate, paginationValidator, setDefaultSort, setDefaultPagination, videosAddValidator, videosGetValidator,
18 videosRemoveValidator, videosSearchValidator, videosSortValidator, videosUpdateValidator 18 videosRemoveValidator, videosSearchValidator, videosSortValidator, videosUpdateValidator
@@ -176,18 +176,9 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi
176 ) 176 )
177 await Promise.all(tasks) 177 await Promise.all(tasks)
178 178
179 return sequelizeTypescript.transaction(async t => { 179 const videoCreated = await sequelizeTypescript.transaction(async t => {
180 const sequelizeOptions = { transaction: t } 180 const sequelizeOptions = { transaction: t }
181 181
182 if (CONFIG.TRANSCODING.ENABLED === true) {
183 // Put uuid because we don't have id auto incremented for now
184 const dataInput = {
185 videoUUID: video.uuid
186 }
187
188 await transcodingJobScheduler.createJob(t, 'videoFileOptimizer', dataInput)
189 }
190
191 const videoCreated = await video.save(sequelizeOptions) 182 const videoCreated = await video.save(sequelizeOptions)
192 // Do not forget to add video channel information to the created video 183 // Do not forget to add video channel information to the created video
193 videoCreated.VideoChannel = res.locals.videoChannel 184 videoCreated.VideoChannel = res.locals.videoChannel
@@ -216,6 +207,17 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi
216 207
217 return videoCreated 208 return videoCreated
218 }) 209 })
210
211 if (CONFIG.TRANSCODING.ENABLED === true) {
212 // Put uuid because we don't have id auto incremented for now
213 const dataInput = {
214 videoUUID: videoCreated.uuid
215 }
216
217 await JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput })
218 }
219
220 return videoCreated
219} 221}
220 222
221async function updateVideoRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { 223async function updateVideoRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) {