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