diff options
author | Chocobozzz <me@florianbigard.com> | 2018-12-28 13:47:17 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-01-09 11:15:15 +0100 |
commit | e8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241 (patch) | |
tree | c0986e91e6ed466af075ddac3c795894db4d0b85 /server/lib/job-queue/handlers/video-file.ts | |
parent | cef534ed53e4518fe0acf581bfe880788d42fc36 (diff) | |
download | PeerTube-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.ts | 18 |
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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import * as Bull from 'bull' |
2 | import { VideoResolution, VideoState, Job } from '../../../../shared' | 2 | import { VideoResolution, VideoState } from '../../../../shared' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { VideoModel } from '../../../models/video/video' | 4 | import { VideoModel } from '../../../models/video/video' |
5 | import { JobQueue } from '../job-queue' | 5 | import { JobQueue } from '../job-queue' |
@@ -8,7 +8,7 @@ import { retryTransactionWrapper } from '../../../helpers/database-utils' | |||
8 | import { sequelizeTypescript } from '../../../initializers' | 8 | import { sequelizeTypescript } from '../../../initializers' |
9 | import * as Bluebird from 'bluebird' | 9 | import * as Bluebird from 'bluebird' |
10 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' | 10 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' |
11 | import { importVideoFile, transcodeOriginalVideofile, optimizeVideofile } from '../../video-transcoding' | 11 | import { importVideoFile, optimizeVideofile, transcodeOriginalVideofile } from '../../video-transcoding' |
12 | import { Notifier } from '../../notifier' | 12 | import { Notifier } from '../../notifier' |
13 | 13 | ||
14 | export type VideoFilePayload = { | 14 | export type VideoFilePayload = { |
@@ -68,7 +68,7 @@ async function processVideoFile (job: Bull.Job) { | |||
68 | async function onVideoFileTranscoderOrImportSuccess (video: VideoModel) { | 68 | async 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 | ||
96 | async function onVideoFileOptimizerSuccess (videoArg: VideoModel, isNewVideo: boolean) { | 97 | async 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 | // --------------------------------------------------------------------------- |