aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
blob: f21da087e9b80e127c4aac21eded92a1b4071a52 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
                            
                                                
                                                             
                                                                              

                                                                
 



                                             
                                                              


                                                                  
 
                                   
                                                                                 


   


                                                                              
                               
 
import * as Bull from 'bull'
import { logger } from '../../../helpers/logger'
import { processActivities } from '../../activitypub/process'
import { ActivitypubHttpBroadcastPayload } from './activitypub-http-broadcast'
import { crawlCollectionPage } from '../../activitypub/crawl'
import { Activity } from '../../../../shared/models/activitypub'

export type ActivitypubHttpFetcherPayload = {
  uris: string[]
}

async function processActivityPubHttpFetcher (job: Bull.Job) {
  logger.info('Processing ActivityPub fetcher in job %d.', job.id)

  const payload = job.data as ActivitypubHttpBroadcastPayload

  for (const uri of payload.uris) {
    await crawlCollectionPage<Activity>(uri, (items) => processActivities(items))
  }
}

// ---------------------------------------------------------------------------

export {
  processActivityPubHttpFetcher
}