aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers/video-transcoding.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-10-28 10:49:20 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commitd846d99c6c81028bb7bd3cb20abd433cbf396a22 (patch)
tree1090abd56e9b2df82dd92783f499ac9f10fbd501 /server/lib/job-queue/handlers/video-transcoding.ts
parent31c82cd914e13dbf53280d0aad0740d70c414441 (diff)
downloadPeerTube-d846d99c6c81028bb7bd3cb20abd433cbf396a22.tar.gz
PeerTube-d846d99c6c81028bb7bd3cb20abd433cbf396a22.tar.zst
PeerTube-d846d99c6c81028bb7bd3cb20abd433cbf396a22.zip
Add modal to display live information
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}