2021-06-03 10:02:29 -04:00
|
|
|
import { logger } from '@server/helpers/logger'
|
|
|
|
import { ActorModel } from '@server/models/actor/actor'
|
|
|
|
import { getServerActor } from '@server/models/application/application'
|
|
|
|
import { JobQueue } from '../job-queue'
|
|
|
|
|
|
|
|
async function addFetchOutboxJob (actor: Pick<ActorModel, 'id' | 'outboxUrl'>) {
|
|
|
|
// Don't fetch ourselves
|
|
|
|
const serverActor = await getServerActor()
|
|
|
|
if (serverActor.id === actor.id) {
|
|
|
|
logger.error('Cannot fetch our own outbox!')
|
|
|
|
return undefined
|
|
|
|
}
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
uri: actor.outboxUrl,
|
|
|
|
type: 'activity' as 'activity'
|
|
|
|
}
|
|
|
|
|
2022-08-08 09:48:17 -04:00
|
|
|
return JobQueue.Instance.createJobAsync({ type: 'activitypub-http-fetcher', payload })
|
2021-06-03 10:02:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
addFetchOutboxJob
|
|
|
|
}
|