From 418d092afa81e2c8fe8ac6838fc4b5eb0af6a782 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 26 Feb 2019 10:55:40 +0100 Subject: Playlist server API --- server/lib/job-queue/handlers/activitypub-http-fetcher.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'server/lib/job-queue/handlers') 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' import { crawlCollectionPage } from '../../activitypub/crawl' import { VideoModel } from '../../../models/video/video' import { addVideoShares, createRates } from '../../activitypub' +import { createAccountPlaylists } from '../../activitypub/playlist' +import { AccountModel } from '../../../models/account/account' -type FetchType = 'activity' | 'video-likes' | 'video-dislikes' | 'video-shares' | 'video-comments' +type FetchType = 'activity' | 'video-likes' | 'video-dislikes' | 'video-shares' | 'video-comments' | 'account-playlists' export type ActivitypubHttpFetcherPayload = { uri: string type: FetchType videoId?: number + accountId?: number } async function processActivityPubHttpFetcher (job: Bull.Job) { @@ -22,12 +25,16 @@ async function processActivityPubHttpFetcher (job: Bull.Job) { let video: VideoModel if (payload.videoId) video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoId) + let account: AccountModel + if (payload.accountId) account = await AccountModel.load(payload.accountId) + const fetcherType: { [ id in FetchType ]: (items: any[]) => Promise } = { 'activity': items => processActivities(items, { outboxUrl: payload.uri }), 'video-likes': items => createRates(items, video, 'like'), 'video-dislikes': items => createRates(items, video, 'dislike'), 'video-shares': items => addVideoShares(items, video), - 'video-comments': items => addVideoComments(items, video) + 'video-comments': items => addVideoComments(items, video), + 'account-playlists': items => createAccountPlaylists(items, account) } return crawlCollectionPage(payload.uri, fetcherType[payload.type]) -- cgit v1.2.3