]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/job-queue/handlers/activitypub-http-fetcher.ts
Merge branch 'master' into develop
[github/Chocobozzz/PeerTube.git] / server / lib / job-queue / handlers / activitypub-http-fetcher.ts
index 4da645f072e0e8d475e1277f666bbb546e79b06f..524aadc27af33365d26d4225323bbcdbd573ce9b 100644 (file)
@@ -5,31 +5,25 @@ import { processActivities } from '../../activitypub/process'
 import { addVideoComments } from '../../activitypub/video-comments'
 import { crawlCollectionPage } from '../../activitypub/crawl'
 import { VideoModel } from '../../../models/video/video'
-import { addVideoShares, createRates } from '../../activitypub'
+import { addVideoShares } from '../../activitypub/share'
+import { createRates } from '../../activitypub/video-rates'
 import { createAccountPlaylists } from '../../activitypub/playlist'
 import { AccountModel } from '../../../models/account/account'
 import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
 import { VideoShareModel } from '../../../models/video/video-share'
 import { VideoCommentModel } from '../../../models/video/video-comment'
-
-type FetchType = 'activity' | 'video-likes' | 'video-dislikes' | 'video-shares' | 'video-comments' | 'account-playlists'
-
-export type ActivitypubHttpFetcherPayload = {
-  uri: string
-  type: FetchType
-  videoId?: number
-  accountId?: number
-}
+import { MAccountDefault, MVideoFullLight } from '../../../typings/models'
+import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models'
 
 async function processActivityPubHttpFetcher (job: Bull.Job) {
   logger.info('Processing ActivityPub fetcher in job %d.', job.id)
 
   const payload = job.data as ActivitypubHttpFetcherPayload
 
-  let video: VideoModel
+  let video: MVideoFullLight
   if (payload.videoId) video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoId)
 
-  let account: AccountModel
+  let account: MAccountDefault
   if (payload.accountId) account = await AccountModel.load(payload.accountId)
 
   const fetcherType: { [ id in FetchType ]: (items: any[]) => Promise<any> } = {
@@ -37,7 +31,7 @@ async function processActivityPubHttpFetcher (job: Bull.Job) {
     '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),
     'account-playlists': items => createAccountPlaylists(items, account)
   }