aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/job-queue/handlers')
-rw-r--r--server/lib/job-queue/handlers/activitypub-http-fetcher.ts11
1 files changed, 9 insertions, 2 deletions
diff --git a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
index 67ccfa995..52225f64f 100644
--- a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
@@ -5,13 +5,16 @@ import { addVideoComments } from '../../activitypub/video-comments'
5import { crawlCollectionPage } from '../../activitypub/crawl' 5import { crawlCollectionPage } from '../../activitypub/crawl'
6import { VideoModel } from '../../../models/video/video' 6import { VideoModel } from '../../../models/video/video'
7import { addVideoShares, createRates } from '../../activitypub' 7import { addVideoShares, createRates } from '../../activitypub'
8import { createAccountPlaylists } from '../../activitypub/playlist'
9import { AccountModel } from '../../../models/account/account'
8 10
9type FetchType = 'activity' | 'video-likes' | 'video-dislikes' | 'video-shares' | 'video-comments' 11type FetchType = 'activity' | 'video-likes' | 'video-dislikes' | 'video-shares' | 'video-comments' | 'account-playlists'
10 12
11export type ActivitypubHttpFetcherPayload = { 13export type ActivitypubHttpFetcherPayload = {
12 uri: string 14 uri: string
13 type: FetchType 15 type: FetchType
14 videoId?: number 16 videoId?: number
17 accountId?: number
15} 18}
16 19
17async function processActivityPubHttpFetcher (job: Bull.Job) { 20async function processActivityPubHttpFetcher (job: Bull.Job) {
@@ -22,12 +25,16 @@ async function processActivityPubHttpFetcher (job: Bull.Job) {
22 let video: VideoModel 25 let video: VideoModel
23 if (payload.videoId) video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoId) 26 if (payload.videoId) video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoId)
24 27
28 let account: AccountModel
29 if (payload.accountId) account = await AccountModel.load(payload.accountId)
30
25 const fetcherType: { [ id in FetchType ]: (items: any[]) => Promise<any> } = { 31 const fetcherType: { [ id in FetchType ]: (items: any[]) => Promise<any> } = {
26 'activity': items => processActivities(items, { outboxUrl: payload.uri }), 32 'activity': items => processActivities(items, { outboxUrl: payload.uri }),
27 'video-likes': items => createRates(items, video, 'like'), 33 'video-likes': items => createRates(items, video, 'like'),
28 'video-dislikes': items => createRates(items, video, 'dislike'), 34 'video-dislikes': items => createRates(items, video, 'dislike'),
29 'video-shares': items => addVideoShares(items, video), 35 'video-shares': items => addVideoShares(items, video),
30 'video-comments': items => addVideoComments(items, video) 36 'video-comments': items => addVideoComments(items, video),
37 'account-playlists': items => createAccountPlaylists(items, account)
31 } 38 }
32 39
33 return crawlCollectionPage(payload.uri, fetcherType[payload.type]) 40 return crawlCollectionPage(payload.uri, fetcherType[payload.type])