diff options
Diffstat (limited to 'server/lib/job-queue')
-rw-r--r-- | server/lib/job-queue/handlers/activitypub-http-fetcher.ts | 4 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-file.ts | 15 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-import.ts | 2 |
3 files changed, 11 insertions, 10 deletions
diff --git a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts index 72d670277..42217c27c 100644 --- a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts +++ b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts | |||
@@ -1,10 +1,10 @@ | |||
1 | import * as Bull from 'bull' | 1 | import * as Bull from 'bull' |
2 | import { logger } from '../../../helpers/logger' | 2 | import { logger } from '../../../helpers/logger' |
3 | import { processActivities } from '../../activitypub/process' | 3 | import { processActivities } from '../../activitypub/process' |
4 | import { VideoModel } from '../../../models/video/video' | ||
5 | import { addVideoShares, createRates } from '../../activitypub/videos' | ||
6 | import { addVideoComments } from '../../activitypub/video-comments' | 4 | import { addVideoComments } from '../../activitypub/video-comments' |
7 | import { crawlCollectionPage } from '../../activitypub/crawl' | 5 | import { crawlCollectionPage } from '../../activitypub/crawl' |
6 | import { VideoModel } from '../../../models/video/video' | ||
7 | import { addVideoShares, createRates } from '../../activitypub' | ||
8 | 8 | ||
9 | type FetchType = 'activity' | 'video-likes' | 'video-dislikes' | 'video-shares' | 'video-comments' | 9 | type FetchType = 'activity' | 'video-likes' | 'video-dislikes' | 'video-shares' | 'video-comments' |
10 | 10 | ||
diff --git a/server/lib/job-queue/handlers/video-file.ts b/server/lib/job-queue/handlers/video-file.ts index c6308f7a6..1463c93fc 100644 --- a/server/lib/job-queue/handlers/video-file.ts +++ b/server/lib/job-queue/handlers/video-file.ts | |||
@@ -8,6 +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, optimizeOriginalVideofile } from '../../video-transcoding' | ||
11 | 12 | ||
12 | export type VideoFilePayload = { | 13 | export type VideoFilePayload = { |
13 | videoUUID: string | 14 | videoUUID: string |
@@ -25,14 +26,14 @@ async function processVideoFileImport (job: Bull.Job) { | |||
25 | const payload = job.data as VideoFileImportPayload | 26 | const payload = job.data as VideoFileImportPayload |
26 | logger.info('Processing video file import in job %d.', job.id) | 27 | logger.info('Processing video file import in job %d.', job.id) |
27 | 28 | ||
28 | const video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(payload.videoUUID) | 29 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID) |
29 | // No video, maybe deleted? | 30 | // No video, maybe deleted? |
30 | if (!video) { | 31 | if (!video) { |
31 | logger.info('Do not process job %d, video does not exist.', job.id) | 32 | logger.info('Do not process job %d, video does not exist.', job.id) |
32 | return undefined | 33 | return undefined |
33 | } | 34 | } |
34 | 35 | ||
35 | await video.importVideoFile(payload.filePath) | 36 | await importVideoFile(video, payload.filePath) |
36 | 37 | ||
37 | await onVideoFileTranscoderOrImportSuccess(video) | 38 | await onVideoFileTranscoderOrImportSuccess(video) |
38 | return video | 39 | return video |
@@ -42,7 +43,7 @@ async function processVideoFile (job: Bull.Job) { | |||
42 | const payload = job.data as VideoFilePayload | 43 | const payload = job.data as VideoFilePayload |
43 | logger.info('Processing video file in job %d.', job.id) | 44 | logger.info('Processing video file in job %d.', job.id) |
44 | 45 | ||
45 | const video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(payload.videoUUID) | 46 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID) |
46 | // No video, maybe deleted? | 47 | // No video, maybe deleted? |
47 | if (!video) { | 48 | if (!video) { |
48 | logger.info('Do not process job %d, video does not exist.', job.id) | 49 | logger.info('Do not process job %d, video does not exist.', job.id) |
@@ -51,11 +52,11 @@ async function processVideoFile (job: Bull.Job) { | |||
51 | 52 | ||
52 | // Transcoding in other resolution | 53 | // Transcoding in other resolution |
53 | if (payload.resolution) { | 54 | if (payload.resolution) { |
54 | await video.transcodeOriginalVideofile(payload.resolution, payload.isPortraitMode || false) | 55 | await transcodeOriginalVideofile(video, payload.resolution, payload.isPortraitMode || false) |
55 | 56 | ||
56 | await retryTransactionWrapper(onVideoFileTranscoderOrImportSuccess, video) | 57 | await retryTransactionWrapper(onVideoFileTranscoderOrImportSuccess, video) |
57 | } else { | 58 | } else { |
58 | await video.optimizeOriginalVideofile() | 59 | await optimizeOriginalVideofile(video) |
59 | 60 | ||
60 | await retryTransactionWrapper(onVideoFileOptimizerSuccess, video, payload.isNewVideo) | 61 | await retryTransactionWrapper(onVideoFileOptimizerSuccess, video, payload.isNewVideo) |
61 | } | 62 | } |
@@ -68,7 +69,7 @@ async function onVideoFileTranscoderOrImportSuccess (video: VideoModel) { | |||
68 | 69 | ||
69 | return sequelizeTypescript.transaction(async t => { | 70 | return sequelizeTypescript.transaction(async t => { |
70 | // Maybe the video changed in database, refresh it | 71 | // Maybe the video changed in database, refresh it |
71 | let videoDatabase = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(video.uuid, t) | 72 | let videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t) |
72 | // Video does not exist anymore | 73 | // Video does not exist anymore |
73 | if (!videoDatabase) return undefined | 74 | if (!videoDatabase) return undefined |
74 | 75 | ||
@@ -98,7 +99,7 @@ async function onVideoFileOptimizerSuccess (video: VideoModel, isNewVideo: boole | |||
98 | 99 | ||
99 | return sequelizeTypescript.transaction(async t => { | 100 | return sequelizeTypescript.transaction(async t => { |
100 | // Maybe the video changed in database, refresh it | 101 | // Maybe the video changed in database, refresh it |
101 | const videoDatabase = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(video.uuid, t) | 102 | const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t) |
102 | // Video does not exist anymore | 103 | // Video does not exist anymore |
103 | if (!videoDatabase) return undefined | 104 | if (!videoDatabase) return undefined |
104 | 105 | ||
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index ebcb2090c..9e14e57e6 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts | |||
@@ -183,7 +183,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide | |||
183 | const videoUpdated = await video.save({ transaction: t }) | 183 | const videoUpdated = await video.save({ transaction: t }) |
184 | 184 | ||
185 | // Now we can federate the video (reload from database, we need more attributes) | 185 | // Now we can federate the video (reload from database, we need more attributes) |
186 | const videoForFederation = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(video.uuid, t) | 186 | const videoForFederation = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t) |
187 | await federateVideoIfNeeded(videoForFederation, true, t) | 187 | await federateVideoIfNeeded(videoForFederation, true, t) |
188 | 188 | ||
189 | // Update video import object | 189 | // Update video import object |