1 import { Job } from 'bullmq'
2 import { Notifier } from '@server/lib/notifier'
3 import { VideoModel } from '@server/models/video/video'
4 import { NotifyPayload } from '@shared/models'
5 import { logger } from '../../../helpers/logger'
7 async function processNotify (job: Job) {
8 const payload = job.data as NotifyPayload
9 logger.info('Processing %s notification in job %s.', payload.action, job.id)
11 if (payload.action === 'new-video') return doNotifyNewVideo(payload)
14 // ---------------------------------------------------------------------------
20 // ---------------------------------------------------------------------------
22 async function doNotifyNewVideo (payload: NotifyPayload & { action: 'new-video' }) {
23 const refreshedVideo = await VideoModel.loadFull(payload.videoUUID)
24 if (!refreshedVideo) return
26 Notifier.Instance.notifyOnNewVideoIfNeeded(refreshedVideo)