diff options
Diffstat (limited to 'server/lib/activitypub/activity.ts')
-rw-r--r-- | server/lib/activitypub/activity.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/server/lib/activitypub/activity.ts b/server/lib/activitypub/activity.ts new file mode 100644 index 000000000..215b50b69 --- /dev/null +++ b/server/lib/activitypub/activity.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | import { signJsonLDObject } from '@server/helpers/peertube-crypto' | ||
2 | import { MActor } from '@server/types/models' | ||
3 | import { ContextType } from '@shared/models' | ||
4 | import { activityPubContextify } from './context' | ||
5 | |||
6 | function buildSignedActivity <T> (byActor: MActor, data: T, contextType?: ContextType) { | ||
7 | const activity = activityPubContextify(data, contextType) | ||
8 | |||
9 | return signJsonLDObject(byActor, activity) | ||
10 | } | ||
11 | |||
12 | function getAPId (object: string | { id: string }) { | ||
13 | if (typeof object === 'string') return object | ||
14 | |||
15 | return object.id | ||
16 | } | ||
17 | |||
18 | export { | ||
19 | buildSignedActivity, | ||
20 | getAPId | ||
21 | } | ||