]>
Commit | Line | Data |
---|---|---|
1 | import { Job } from 'bullmq' | |
2 | import { retryTransactionWrapper } from '@server/helpers/database-utils' | |
3 | import { sequelizeTypescript } from '@server/initializers/database' | |
4 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' | |
5 | import { VideoModel } from '@server/models/video/video' | |
6 | import { FederateVideoPayload } from '@shared/models' | |
7 | import { logger } from '../../../helpers/logger' | |
8 | ||
9 | function processFederateVideo (job: Job) { | |
10 | const payload = job.data as FederateVideoPayload | |
11 | ||
12 | logger.info('Processing video federation in job %s.', job.id) | |
13 | ||
14 | return retryTransactionWrapper(() => { | |
15 | return sequelizeTypescript.transaction(async t => { | |
16 | const video = await VideoModel.loadFull(payload.videoUUID, t) | |
17 | if (!video) return | |
18 | ||
19 | return federateVideoIfNeeded(video, payload.isNewVideo, t) | |
20 | }) | |
21 | }) | |
22 | } | |
23 | ||
24 | // --------------------------------------------------------------------------- | |
25 | ||
26 | export { | |
27 | processFederateVideo | |
28 | } |