From 94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 25 Jan 2018 15:05:18 +0100 Subject: Move job queue to redis We'll use it as cache in the future. /!\ You'll loose your old jobs (pending jobs too) so upgrade only when you don't have pending job anymore. --- .../activitypub-http-fetcher-handler.ts | 68 ---------------------- 1 file changed, 68 deletions(-) delete mode 100644 server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-fetcher-handler.ts (limited to 'server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-fetcher-handler.ts') diff --git a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-fetcher-handler.ts b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-fetcher-handler.ts deleted file mode 100644 index a7b5aabd0..000000000 --- a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-fetcher-handler.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { logger } from '../../../helpers/logger' -import { doRequest } from '../../../helpers/requests' -import { ACTIVITY_PUB } from '../../../initializers' -import { processActivities } from '../../activitypub/process' -import { ActivityPubHttpPayload } from './activitypub-http-job-scheduler' - -async function process (payload: ActivityPubHttpPayload, jobId: number) { - logger.info('Processing ActivityPub fetcher in job %d.', jobId) - - const options = { - method: 'GET', - uri: '', - json: true, - activityPub: true - } - - for (const uri of payload.uris) { - options.uri = uri - logger.info('Fetching ActivityPub data on %s.', uri) - - const response = await doRequest(options) - const firstBody = response.body - - if (firstBody.first && Array.isArray(firstBody.first.orderedItems)) { - const activities = firstBody.first.orderedItems - - logger.info('Processing %i items ActivityPub fetcher for %s.', activities.length, options.uri) - - await processActivities(activities) - } - - let limit = ACTIVITY_PUB.FETCH_PAGE_LIMIT - let i = 0 - let nextLink = firstBody.first.next - while (nextLink && i < limit) { - options.uri = nextLink - - const { body } = await doRequest(options) - nextLink = body.next - i++ - - if (Array.isArray(body.orderedItems)) { - const activities = body.orderedItems - logger.info('Processing %i items ActivityPub fetcher for %s.', activities.length, options.uri) - - await processActivities(activities) - } - } - } -} - -function onError (err: Error, jobId: number) { - logger.error('Error when fetcher ActivityPub request in job %d.', jobId, err) - return Promise.resolve() -} - -function onSuccess (jobId: number) { - logger.info('Job %d is a success.', jobId) - return Promise.resolve() -} - -// --------------------------------------------------------------------------- - -export { - process, - onError, - onSuccess -} -- cgit v1.2.3