aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/outbox.ts
blob: 5eef7687118ede1b33c07dd28a1c1c2d0a71626a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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'
  }

  return JobQueue.Instance.createJobAsync({ type: 'activitypub-http-fetcher', payload })
}

export {
  addFetchOutboxJob
}