aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers/video-file.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-12-28 13:47:17 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-01-09 11:15:15 +0100
commite8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241 (patch)
treec0986e91e6ed466af075ddac3c795894db4d0b85 /server/lib/job-queue/handlers/video-file.ts
parentcef534ed53e4518fe0acf581bfe880788d42fc36 (diff)
downloadPeerTube-e8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241.tar.gz
PeerTube-e8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241.tar.zst
PeerTube-e8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241.zip
Add notification settings migration
Diffstat (limited to 'server/lib/job-queue/handlers/video-file.ts')
-rw-r--r--server/lib/job-queue/handlers/video-file.ts18
1 files changed, 11 insertions, 7 deletions
diff --git a/server/lib/job-queue/handlers/video-file.ts b/server/lib/job-queue/handlers/video-file.ts
index 959cc04fa..480d324dc 100644
--- a/server/lib/job-queue/handlers/video-file.ts
+++ b/server/lib/job-queue/handlers/video-file.ts
@@ -1,5 +1,5 @@
1import * as Bull from 'bull' 1import * as Bull from 'bull'
2import { VideoResolution, VideoState, Job } from '../../../../shared' 2import { VideoResolution, VideoState } from '../../../../shared'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
4import { VideoModel } from '../../../models/video/video' 4import { VideoModel } from '../../../models/video/video'
5import { JobQueue } from '../job-queue' 5import { JobQueue } from '../job-queue'
@@ -8,7 +8,7 @@ import { retryTransactionWrapper } from '../../../helpers/database-utils'
8import { sequelizeTypescript } from '../../../initializers' 8import { sequelizeTypescript } from '../../../initializers'
9import * as Bluebird from 'bluebird' 9import * as Bluebird from 'bluebird'
10import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' 10import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils'
11import { importVideoFile, transcodeOriginalVideofile, optimizeVideofile } from '../../video-transcoding' 11import { importVideoFile, optimizeVideofile, transcodeOriginalVideofile } from '../../video-transcoding'
12import { Notifier } from '../../notifier' 12import { Notifier } from '../../notifier'
13 13
14export type VideoFilePayload = { 14export type VideoFilePayload = {
@@ -68,7 +68,7 @@ async function processVideoFile (job: Bull.Job) {
68async function onVideoFileTranscoderOrImportSuccess (video: VideoModel) { 68async function onVideoFileTranscoderOrImportSuccess (video: VideoModel) {
69 if (video === undefined) return undefined 69 if (video === undefined) return undefined
70 70
71 return sequelizeTypescript.transaction(async t => { 71 const { videoDatabase, isNewVideo } = await sequelizeTypescript.transaction(async t => {
72 // Maybe the video changed in database, refresh it 72 // Maybe the video changed in database, refresh it
73 let videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t) 73 let videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t)
74 // Video does not exist anymore 74 // Video does not exist anymore
@@ -87,10 +87,11 @@ async function onVideoFileTranscoderOrImportSuccess (video: VideoModel) {
87 87
88 // If the video was not published, we consider it is a new one for other instances 88 // If the video was not published, we consider it is a new one for other instances
89 await federateVideoIfNeeded(videoDatabase, isNewVideo, t) 89 await federateVideoIfNeeded(videoDatabase, isNewVideo, t)
90 if (isNewVideo) Notifier.Instance.notifyOnNewVideo(video)
91 90
92 return undefined 91 return { videoDatabase, isNewVideo }
93 }) 92 })
93
94 if (isNewVideo) Notifier.Instance.notifyOnNewVideo(videoDatabase)
94} 95}
95 96
96async function onVideoFileOptimizerSuccess (videoArg: VideoModel, isNewVideo: boolean) { 97async function onVideoFileOptimizerSuccess (videoArg: VideoModel, isNewVideo: boolean) {
@@ -99,7 +100,7 @@ async function onVideoFileOptimizerSuccess (videoArg: VideoModel, isNewVideo: bo
99 // Outside the transaction (IO on disk) 100 // Outside the transaction (IO on disk)
100 const { videoFileResolution } = await videoArg.getOriginalFileResolution() 101 const { videoFileResolution } = await videoArg.getOriginalFileResolution()
101 102
102 return sequelizeTypescript.transaction(async t => { 103 const videoDatabase = await sequelizeTypescript.transaction(async t => {
103 // Maybe the video changed in database, refresh it 104 // Maybe the video changed in database, refresh it
104 let videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid, t) 105 let videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid, t)
105 // Video does not exist anymore 106 // Video does not exist anymore
@@ -137,8 +138,11 @@ async function onVideoFileOptimizerSuccess (videoArg: VideoModel, isNewVideo: bo
137 } 138 }
138 139
139 await federateVideoIfNeeded(videoDatabase, isNewVideo, t) 140 await federateVideoIfNeeded(videoDatabase, isNewVideo, t)
140 if (isNewVideo) Notifier.Instance.notifyOnNewVideo(videoDatabase) 141
142 return videoDatabase
141 }) 143 })
144
145 if (isNewVideo) Notifier.Instance.notifyOnNewVideo(videoDatabase)
142} 146}
143 147
144// --------------------------------------------------------------------------- 148// ---------------------------------------------------------------------------