2022-08-08 08:48:17 -05:00
|
|
|
import { Job } from 'bullmq'
|
2023-07-31 07:34:36 -05:00
|
|
|
import { Notifier } from '@server/lib/notifier/index.js'
|
|
|
|
import { VideoModel } from '@server/models/video/video.js'
|
|
|
|
import { NotifyPayload } from '@peertube/peertube-models'
|
|
|
|
import { logger } from '../../../helpers/logger.js'
|
2022-08-08 08:48:17 -05:00
|
|
|
|
|
|
|
async function processNotify (job: Job) {
|
|
|
|
const payload = job.data as NotifyPayload
|
|
|
|
logger.info('Processing %s notification in job %s.', payload.action, job.id)
|
|
|
|
|
|
|
|
if (payload.action === 'new-video') return doNotifyNewVideo(payload)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
processNotify
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
async function doNotifyNewVideo (payload: NotifyPayload & { action: 'new-video' }) {
|
|
|
|
const refreshedVideo = await VideoModel.loadFull(payload.videoUUID)
|
|
|
|
if (!refreshedVideo) return
|
|
|
|
|
2024-02-15 06:55:12 -06:00
|
|
|
Notifier.Instance.notifyOnNewVideoOrLiveIfNeeded(refreshedVideo)
|
2022-08-08 08:48:17 -05:00
|
|
|
}
|