2018-02-23 08:09:12 -06:00
|
|
|
import { logger } from '../../helpers/logger'
|
|
|
|
import { getServerActor } from '../../helpers/utils'
|
2017-12-14 10:38:41 -06:00
|
|
|
import { ActorModel } from '../../models/activitypub/actor'
|
2018-01-25 08:05:18 -06:00
|
|
|
import { JobQueue } from '../job-queue'
|
2017-11-22 03:29:55 -06:00
|
|
|
|
2018-01-25 08:05:18 -06:00
|
|
|
async function addFetchOutboxJob (actor: ActorModel) {
|
2018-02-23 08:09:12 -06:00
|
|
|
// Don't fetch ourselves
|
|
|
|
const serverActor = await getServerActor()
|
|
|
|
if (serverActor.id === actor.id) {
|
|
|
|
logger.error('Cannot fetch our own outbox!')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-01-25 08:05:18 -06:00
|
|
|
const payload = {
|
2017-12-14 10:38:41 -06:00
|
|
|
uris: [ actor.outboxUrl ]
|
2017-11-22 03:29:55 -06:00
|
|
|
}
|
|
|
|
|
2018-01-25 08:05:18 -06:00
|
|
|
return JobQueue.Instance.createJob({ type: 'activitypub-http-fetcher', payload })
|
2017-11-22 03:29:55 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
addFetchOutboxJob
|
|
|
|
}
|