diff options
Diffstat (limited to 'server/lib/job-queue/handlers/activitypub-http-fetcher.ts')
-rw-r--r-- | server/lib/job-queue/handlers/activitypub-http-fetcher.ts | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts deleted file mode 100644 index b6cb3c4a6..000000000 --- a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | import { Job } from 'bullmq' | ||
2 | import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models' | ||
3 | import { logger } from '../../../helpers/logger' | ||
4 | import { VideoModel } from '../../../models/video/video' | ||
5 | import { VideoCommentModel } from '../../../models/video/video-comment' | ||
6 | import { VideoShareModel } from '../../../models/video/video-share' | ||
7 | import { MVideoFullLight } from '../../../types/models' | ||
8 | import { crawlCollectionPage } from '../../activitypub/crawl' | ||
9 | import { createAccountPlaylists } from '../../activitypub/playlists' | ||
10 | import { processActivities } from '../../activitypub/process' | ||
11 | import { addVideoShares } from '../../activitypub/share' | ||
12 | import { addVideoComments } from '../../activitypub/video-comments' | ||
13 | |||
14 | async function processActivityPubHttpFetcher (job: Job) { | ||
15 | logger.info('Processing ActivityPub fetcher in job %s.', job.id) | ||
16 | |||
17 | const payload = job.data as ActivitypubHttpFetcherPayload | ||
18 | |||
19 | let video: MVideoFullLight | ||
20 | if (payload.videoId) video = await VideoModel.loadFull(payload.videoId) | ||
21 | |||
22 | const fetcherType: { [ id in FetchType ]: (items: any[]) => Promise<any> } = { | ||
23 | 'activity': items => processActivities(items, { outboxUrl: payload.uri, fromFetch: true }), | ||
24 | 'video-shares': items => addVideoShares(items, video), | ||
25 | 'video-comments': items => addVideoComments(items), | ||
26 | 'account-playlists': items => createAccountPlaylists(items) | ||
27 | } | ||
28 | |||
29 | const cleanerType: { [ id in FetchType ]?: (crawlStartDate: Date) => Promise<any> } = { | ||
30 | 'video-shares': crawlStartDate => VideoShareModel.cleanOldSharesOf(video.id, crawlStartDate), | ||
31 | 'video-comments': crawlStartDate => VideoCommentModel.cleanOldCommentsOf(video.id, crawlStartDate) | ||
32 | } | ||
33 | |||
34 | return crawlCollectionPage(payload.uri, fetcherType[payload.type], cleanerType[payload.type]) | ||
35 | } | ||
36 | |||
37 | // --------------------------------------------------------------------------- | ||
38 | |||
39 | export { | ||
40 | processActivityPubHttpFetcher | ||
41 | } | ||