2022-08-08 15:48:17 +02:00
|
|
|
import { Job } from 'bullmq'
|
2023-07-31 14:34:36 +02:00
|
|
|
import { retryTransactionWrapper } from '@server/helpers/database-utils.js'
|
|
|
|
import { sequelizeTypescript } from '@server/initializers/database.js'
|
|
|
|
import { federateVideoIfNeeded } from '@server/lib/activitypub/videos/index.js'
|
|
|
|
import { VideoModel } from '@server/models/video/video.js'
|
|
|
|
import { FederateVideoPayload } from '@peertube/peertube-models'
|
|
|
|
import { logger } from '../../../helpers/logger.js'
|
2022-08-08 15:48:17 +02:00
|
|
|
|
|
|
|
function processFederateVideo (job: Job) {
|
|
|
|
const payload = job.data as FederateVideoPayload
|
|
|
|
|
|
|
|
logger.info('Processing video federation in job %s.', job.id)
|
|
|
|
|
|
|
|
return retryTransactionWrapper(() => {
|
|
|
|
return sequelizeTypescript.transaction(async t => {
|
|
|
|
const video = await VideoModel.loadFull(payload.videoUUID, t)
|
|
|
|
if (!video) return
|
|
|
|
|
2023-12-15 14:52:12 +01:00
|
|
|
return federateVideoIfNeeded(video, payload.isNewVideoForFederation, t)
|
2022-08-08 15:48:17 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
processFederateVideo
|
|
|
|
}
|