]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/activitypub/activity.ts
Merge branch 'feature/improve-live' into develop
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / activity.ts
CommitLineData
7e0f50d6 1import { ActivityType } from '@shared/models'
630d0a1b 2
7e98a7df
C
3function getAPId (object: string | { id: string }) {
4 if (typeof object === 'string') return object
5
6 return object.id
7}
8
b2111066
C
9function getActivityStreamDuration (duration: number) {
10 // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
11 return 'PT' + duration + 'S'
12}
13
14function getDurationFromActivityStream (duration: string) {
15 return parseInt(duration.replace(/[^\d]+/, ''))
16}
17
630d0a1b
C
18function buildAvailableActivities (): ActivityType[] {
19 return [
20 'Create',
21 'Update',
22 'Delete',
23 'Follow',
24 'Accept',
25 'Announce',
26 'Undo',
27 'Like',
28 'Reject',
29 'View',
30 'Dislike',
31 'Flag'
32 ]
33}
34
7e98a7df 35export {
b2111066
C
36 getAPId,
37 getActivityStreamDuration,
630d0a1b 38 buildAvailableActivities,
b2111066 39 getDurationFromActivityStream
7e98a7df 40}