mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +02:00
Use bullmq job dependency
This commit is contained in:
parent
5a921e7b74
commit
bd911b54b5
42 changed files with 314 additions and 152 deletions
27
server/lib/job-queue/handlers/notify.ts
Normal file
27
server/lib/job-queue/handlers/notify.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { Job } from 'bullmq'
|
||||
import { Notifier } from '@server/lib/notifier'
|
||||
import { VideoModel } from '@server/models/video/video'
|
||||
import { NotifyPayload } from '@shared/models'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
|
||||
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
|
||||
|
||||
Notifier.Instance.notifyOnNewVideoIfNeeded(refreshedVideo)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue