aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers/video-transcoding.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/job-queue/handlers/video-transcoding.ts')
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts23
1 files changed, 1 insertions, 22 deletions
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index 2aebc29f7..843a9f1b5 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -1,4 +1,5 @@
1import * as Bull from 'bull' 1import * as Bull from 'bull'
2import { publishAndFederateIfNeeded } from '@server/lib/video'
2import { getVideoFilePath } from '@server/lib/video-paths' 3import { getVideoFilePath } from '@server/lib/video-paths'
3import { MVideoFullLight, MVideoUUID, MVideoWithFile } from '@server/types/models' 4import { MVideoFullLight, MVideoUUID, MVideoWithFile } from '@server/types/models'
4import { 5import {
@@ -174,25 +175,3 @@ function createHlsJobIfEnabled (payload?: { videoUUID: string, resolution: numbe
174 return JobQueue.Instance.createJob({ type: 'video-transcoding', payload: hlsTranscodingPayload }) 175 return JobQueue.Instance.createJob({ type: 'video-transcoding', payload: hlsTranscodingPayload })
175 } 176 }
176} 177}
177
178async function publishAndFederateIfNeeded (video: MVideoUUID) {
179 const { videoDatabase, videoPublished } = await sequelizeTypescript.transaction(async t => {
180 // Maybe the video changed in database, refresh it
181 const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t)
182 // Video does not exist anymore
183 if (!videoDatabase) return undefined
184
185 // We transcoded the video file in another format, now we can publish it
186 const videoPublished = await videoDatabase.publishIfNeededAndSave(t)
187
188 // If the video was not published, we consider it is a new one for other instances
189 await federateVideoIfNeeded(videoDatabase, videoPublished, t)
190
191 return { videoDatabase, videoPublished }
192 })
193
194 if (videoPublished) {
195 Notifier.Instance.notifyOnNewVideoIfNeeded(videoDatabase)
196 Notifier.Instance.notifyOnVideoPublishedAfterTranscoding(videoDatabase)
197 }
198}