2018-07-10 10:02:20 -05:00
|
|
|
import * as Bull from 'bull'
|
2017-12-28 04:16:08 -06:00
|
|
|
import { logger } from '../../../helpers/logger'
|
2017-12-12 10:53:50 -06:00
|
|
|
import { processActivities } from '../../activitypub/process'
|
2018-01-25 08:05:18 -06:00
|
|
|
import { ActivitypubHttpBroadcastPayload } from './activitypub-http-broadcast'
|
2018-05-25 09:21:16 -05:00
|
|
|
import { crawlCollectionPage } from '../../activitypub/crawl'
|
|
|
|
import { Activity } from '../../../../shared/models/activitypub'
|
2017-11-22 03:29:55 -06:00
|
|
|
|
2018-01-25 08:05:18 -06:00
|
|
|
export type ActivitypubHttpFetcherPayload = {
|
|
|
|
uris: string[]
|
|
|
|
}
|
|
|
|
|
2018-07-10 10:02:20 -05:00
|
|
|
async function processActivityPubHttpFetcher (job: Bull.Job) {
|
2018-01-25 08:05:18 -06:00
|
|
|
logger.info('Processing ActivityPub fetcher in job %d.', job.id)
|
|
|
|
|
|
|
|
const payload = job.data as ActivitypubHttpBroadcastPayload
|
2017-11-22 03:29:55 -06:00
|
|
|
|
|
|
|
for (const uri of payload.uris) {
|
2018-05-25 09:21:16 -05:00
|
|
|
await crawlCollectionPage<Activity>(uri, (items) => processActivities(items))
|
2017-11-22 03:29:55 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
2018-01-25 08:05:18 -06:00
|
|
|
processActivityPubHttpFetcher
|
2017-11-22 03:29:55 -06:00
|
|
|
}
|