diff options
Diffstat (limited to 'server/controllers/api/videos/index.ts')
-rw-r--r-- | server/controllers/api/videos/index.ts | 24 |
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' |
13 | import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServerAndChannel } from '../../../lib/activitypub' | 13 | import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServerAndChannel } from '../../../lib/activitypub' |
14 | import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send' | 14 | import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send' |
15 | import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler' | 15 | import { JobQueue } from '../../../lib/job-queue' |
16 | import { | 16 | import { |
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 | ||
221 | async function updateVideoRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { | 223 | async function updateVideoRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { |