1 import * as Bull from 'bull'
2 import { logger } from '../../../helpers/logger'
3 import { fetchVideoByUrl } from '../../../helpers/video'
4 import { refreshVideoIfNeeded } from '../../activitypub'
6 export type RefreshPayload = {
11 async function refreshAPObject (job: Bull.Job) {
12 const payload = job.data as RefreshPayload
14 logger.info('Processing AP refresher in job %d for video %s.', job.id, payload.videoUrl)
16 if (payload.type === 'video') return refreshAPVideo(payload.videoUrl)
19 // ---------------------------------------------------------------------------
25 // ---------------------------------------------------------------------------
27 async function refreshAPVideo (videoUrl: string) {
28 const fetchType = 'all' as 'all'
29 const syncParam = { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true }
31 const videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType)
32 if (videoFromDatabase) {
33 const refreshOptions = {
34 video: videoFromDatabase,
35 fetchedType: fetchType,
39 await refreshVideoIfNeeded(refreshOptions)