X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fjob-queue%2Fhandlers%2Factivitypub-http-fetcher.ts;h=de533de6c5ef7ce40c07161447b6416410c2e67e;hb=c8fa571f32b10c083fab07f28d2ef55895ef40af;hp=ab9675cae7c2bd70cbb828f1f4c7fbc8177ba4c3;hpb=cf21b2cbef61929177b9c09b5e017c3b7eb8535d;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 ab9675cae..de533de6c 100644 --- a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts +++ b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts @@ -1,7 +1,6 @@ -import * as Bull from 'bull' +import { Job } from 'bull' import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models' import { logger } from '../../../helpers/logger' -import { AccountVideoRateModel } from '../../../models/account/account-video-rate' import { VideoModel } from '../../../models/video/video' import { VideoCommentModel } from '../../../models/video/video-comment' import { VideoShareModel } from '../../../models/video/video-share' @@ -11,28 +10,23 @@ 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) { +async function processActivityPubHttpFetcher (job: Job) { logger.info('Processing ActivityPub fetcher in job %d.', job.id) const payload = job.data as ActivitypubHttpFetcherPayload let video: MVideoFullLight - if (payload.videoId) video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoId) + if (payload.videoId) video = await VideoModel.loadFull(payload.videoId) const fetcherType: { [ id in FetchType ]: (items: any[]) => Promise } = { 'activity': items => processActivities(items, { outboxUrl: payload.uri, fromFetch: true }), - '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), 'account-playlists': items => createAccountPlaylists(items) } 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), 'video-comments': crawlStartDate => VideoCommentModel.cleanOldCommentsOf(video.id, crawlStartDate) }