aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/activity.ts
blob: 215b50b6995305aa7f3a712c96dd11f6ea8d0f55 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { signJsonLDObject } from '@server/helpers/peertube-crypto'
import { MActor } from '@server/types/models'
import { ContextType } from '@shared/models'
import { activityPubContextify } from './context'

function buildSignedActivity <T> (byActor: MActor, data: T, contextType?: ContextType) {
  const activity = activityPubContextify(data, contextType)

  return signJsonLDObject(byActor, activity)
}

function getAPId (object: string | { id: string }) {
  if (typeof object === 'string') return object

  return object.id
}

export {
  buildSignedActivity,
  getAPId
}