X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Flib%2Fjob-queue%2Fhandlers%2Factivitypub-http-fetcher.ts;h=04b25f955958a0c4cdd5423b9e5249c51786576f;hb=7500d6c9000b531fda1fd64e188b7cf83803941a;hp=0182c5169f17ac0c2be83afdee3337499f64fea0;hpb=8c559fad1e1c4c2ab7f1388c73200aa4c6256d74;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts index 0182c5169..04b25f955 100644 --- a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts +++ b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts @@ -1,26 +1,18 @@ import * as Bull from 'bull' -import * as Bluebird from 'bluebird' +import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models' import { logger } from '../../../helpers/logger' -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 { 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 { VideoModel } from '../../../models/video/video' import { VideoCommentModel } from '../../../models/video/video-comment' -import { MAccountDefault, MVideoFullLight } from '../../../typings/models' - -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 { VideoShareModel } from '../../../models/video/video-share' +import { MAccountDefault, MVideoFullLight } from '../../../types/models' +import { crawlCollectionPage } from '../../activitypub/crawl' +import { createAccountPlaylists } from '../../activitypub/playlists' +import { processActivities } from '../../activitypub/process' +import { addVideoShares } from '../../activitypub/share' +import { addVideoComments } from '../../activitypub/video-comments' +import { createRates } from '../../activitypub/video-rates' async function processActivityPubHttpFetcher (job: Bull.Job) { logger.info('Processing ActivityPub fetcher in job %d.', job.id) @@ -42,7 +34,7 @@ async function processActivityPubHttpFetcher (job: Bull.Job) { 'account-playlists': items => createAccountPlaylists(items, account) } - const cleanerType: { [ id in FetchType ]?: (crawlStartDate: Date) => Bluebird } = { + const cleanerType: { [ id in FetchType ]?: (crawlStartDate: Date) => Promise } = { 'video-likes': crawlStartDate => AccountVideoRateModel.cleanOldRatesOf(video.id, 'like' as 'like', crawlStartDate), 'video-dislikes': crawlStartDate => AccountVideoRateModel.cleanOldRatesOf(video.id, 'dislike' as 'dislike', crawlStartDate), 'video-shares': crawlStartDate => VideoShareModel.cleanOldSharesOf(video.id, crawlStartDate),