]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/job-queue/handlers/activitypub-refresher.ts
Fix thumbnail processing
[github/Chocobozzz/PeerTube.git] / server / lib / job-queue / handlers / activitypub-refresher.ts
CommitLineData
04b8c3fb
C
1import * as Bull from 'bull'
2import { logger } from '../../../helpers/logger'
3import { fetchVideoByUrl } from '../../../helpers/video'
4import { refreshVideoIfNeeded } from '../../activitypub'
5
6export type RefreshPayload = {
7 videoUrl: string
8 type: 'video'
9}
10
11async function refreshAPObject (job: Bull.Job) {
12 const payload = job.data as RefreshPayload
74577825
C
13
14 logger.info('Processing AP refresher in job %d for video %s.', job.id, payload.videoUrl)
04b8c3fb
C
15
16 if (payload.type === 'video') return refreshAPVideo(payload.videoUrl)
17}
18
19// ---------------------------------------------------------------------------
20
21export {
22 refreshAPObject
23}
24
25// ---------------------------------------------------------------------------
26
27async function refreshAPVideo (videoUrl: string) {
28 const fetchType = 'all' as 'all'
29 const syncParam = { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true }
30
31 const videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType)
32 if (videoFromDatabase) {
33 const refreshOptions = {
34 video: videoFromDatabase,
35 fetchedType: fetchType,
36 syncParam
37 }
38
39 await refreshVideoIfNeeded(refreshOptions)
40 }
41}