aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/models/src/activitypub
diff options
context:
space:
mode:
Diffstat (limited to 'packages/models/src/activitypub')
-rw-r--r--packages/models/src/activitypub/activity.ts135
-rw-r--r--packages/models/src/activitypub/activitypub-actor.ts34
-rw-r--r--packages/models/src/activitypub/activitypub-collection.ts9
-rw-r--r--packages/models/src/activitypub/activitypub-ordered-collection.ts10
-rw-r--r--packages/models/src/activitypub/activitypub-root.ts5
-rw-r--r--packages/models/src/activitypub/activitypub-signature.ts6
-rw-r--r--packages/models/src/activitypub/context.ts16
-rw-r--r--packages/models/src/activitypub/index.ts9
-rw-r--r--packages/models/src/activitypub/objects/abuse-object.ts15
-rw-r--r--packages/models/src/activitypub/objects/activitypub-object.ts17
-rw-r--r--packages/models/src/activitypub/objects/cache-file-object.ts9
-rw-r--r--packages/models/src/activitypub/objects/common-objects.ts130
-rw-r--r--packages/models/src/activitypub/objects/index.ts9
-rw-r--r--packages/models/src/activitypub/objects/playlist-element-object.ts10
-rw-r--r--packages/models/src/activitypub/objects/playlist-object.ts29
-rw-r--r--packages/models/src/activitypub/objects/video-comment-object.ts16
-rw-r--r--packages/models/src/activitypub/objects/video-object.ts74
-rw-r--r--packages/models/src/activitypub/objects/watch-action-object.ts22
-rw-r--r--packages/models/src/activitypub/webfinger.ts9
19 files changed, 564 insertions, 0 deletions
diff --git a/packages/models/src/activitypub/activity.ts b/packages/models/src/activitypub/activity.ts
new file mode 100644
index 000000000..78a3ab33b
--- /dev/null
+++ b/packages/models/src/activitypub/activity.ts
@@ -0,0 +1,135 @@
1import { ActivityPubActor } from './activitypub-actor.js'
2import { ActivityPubSignature } from './activitypub-signature.js'
3import {
4 ActivityFlagReasonObject,
5 ActivityObject,
6 APObjectId,
7 CacheFileObject,
8 PlaylistObject,
9 VideoCommentObject,
10 VideoObject,
11 WatchActionObject
12} from './objects/index.js'
13
14export type ActivityUpdateObject =
15 Extract<ActivityObject, VideoObject | CacheFileObject | PlaylistObject | ActivityPubActor | string> | ActivityPubActor
16
17// Cannot Extract from Activity because of circular reference
18export type ActivityUndoObject =
19 ActivityFollow | ActivityLike | ActivityDislike | ActivityCreate<CacheFileObject | string> | ActivityAnnounce
20
21export type ActivityCreateObject =
22 Extract<ActivityObject, VideoObject | CacheFileObject | WatchActionObject | VideoCommentObject | PlaylistObject | string>
23
24export type Activity =
25 ActivityCreate<ActivityCreateObject> |
26 ActivityUpdate<ActivityUpdateObject> |
27 ActivityDelete |
28 ActivityFollow |
29 ActivityAccept |
30 ActivityAnnounce |
31 ActivityUndo<ActivityUndoObject> |
32 ActivityLike |
33 ActivityReject |
34 ActivityView |
35 ActivityDislike |
36 ActivityFlag
37
38export type ActivityType =
39 'Create' |
40 'Update' |
41 'Delete' |
42 'Follow' |
43 'Accept' |
44 'Announce' |
45 'Undo' |
46 'Like' |
47 'Reject' |
48 'View' |
49 'Dislike' |
50 'Flag'
51
52export interface ActivityAudience {
53 to: string[]
54 cc: string[]
55}
56
57export interface BaseActivity {
58 '@context'?: any[]
59 id: string
60 to?: string[]
61 cc?: string[]
62 actor: string | ActivityPubActor
63 type: ActivityType
64 signature?: ActivityPubSignature
65}
66
67export interface ActivityCreate <T extends ActivityCreateObject> extends BaseActivity {
68 type: 'Create'
69 object: T
70}
71
72export interface ActivityUpdate <T extends ActivityUpdateObject> extends BaseActivity {
73 type: 'Update'
74 object: T
75}
76
77export interface ActivityDelete extends BaseActivity {
78 type: 'Delete'
79 object: APObjectId
80}
81
82export interface ActivityFollow extends BaseActivity {
83 type: 'Follow'
84 object: string
85}
86
87export interface ActivityAccept extends BaseActivity {
88 type: 'Accept'
89 object: ActivityFollow
90}
91
92export interface ActivityReject extends BaseActivity {
93 type: 'Reject'
94 object: ActivityFollow
95}
96
97export interface ActivityAnnounce extends BaseActivity {
98 type: 'Announce'
99 object: APObjectId
100}
101
102export interface ActivityUndo <T extends ActivityUndoObject> extends BaseActivity {
103 type: 'Undo'
104 object: T
105}
106
107export interface ActivityLike extends BaseActivity {
108 type: 'Like'
109 object: APObjectId
110}
111
112export interface ActivityView extends BaseActivity {
113 type: 'View'
114 actor: string
115 object: APObjectId
116
117 // If sending a "viewer" event
118 expires?: string
119}
120
121export interface ActivityDislike extends BaseActivity {
122 id: string
123 type: 'Dislike'
124 actor: string
125 object: APObjectId
126}
127
128export interface ActivityFlag extends BaseActivity {
129 type: 'Flag'
130 content: string
131 object: APObjectId | APObjectId[]
132 tag?: ActivityFlagReasonObject[]
133 startAt?: number
134 endAt?: number
135}
diff --git a/packages/models/src/activitypub/activitypub-actor.ts b/packages/models/src/activitypub/activitypub-actor.ts
new file mode 100644
index 000000000..85b37c5ad
--- /dev/null
+++ b/packages/models/src/activitypub/activitypub-actor.ts
@@ -0,0 +1,34 @@
1import { ActivityIconObject, ActivityPubAttributedTo } from './objects/common-objects.js'
2
3export type ActivityPubActorType = 'Person' | 'Application' | 'Group' | 'Service' | 'Organization'
4
5export interface ActivityPubActor {
6 '@context': any[]
7 type: ActivityPubActorType
8 id: string
9 following: string
10 followers: string
11 playlists?: string
12 inbox: string
13 outbox: string
14 preferredUsername: string
15 url: string
16 name: string
17 endpoints: {
18 sharedInbox: string
19 }
20 summary: string
21 attributedTo: ActivityPubAttributedTo[]
22
23 support?: string
24 publicKey: {
25 id: string
26 owner: string
27 publicKeyPem: string
28 }
29
30 image?: ActivityIconObject | ActivityIconObject[]
31 icon?: ActivityIconObject | ActivityIconObject[]
32
33 published?: string
34}
diff --git a/packages/models/src/activitypub/activitypub-collection.ts b/packages/models/src/activitypub/activitypub-collection.ts
new file mode 100644
index 000000000..b98ad37c2
--- /dev/null
+++ b/packages/models/src/activitypub/activitypub-collection.ts
@@ -0,0 +1,9 @@
1import { Activity } from './activity.js'
2
3export interface ActivityPubCollection {
4 '@context': string[]
5 type: 'Collection' | 'CollectionPage'
6 totalItems: number
7 partOf?: string
8 items: Activity[]
9}
diff --git a/packages/models/src/activitypub/activitypub-ordered-collection.ts b/packages/models/src/activitypub/activitypub-ordered-collection.ts
new file mode 100644
index 000000000..3de0890bb
--- /dev/null
+++ b/packages/models/src/activitypub/activitypub-ordered-collection.ts
@@ -0,0 +1,10 @@
1export interface ActivityPubOrderedCollection<T> {
2 '@context': string[]
3 type: 'OrderedCollection' | 'OrderedCollectionPage'
4 totalItems: number
5 orderedItems: T[]
6
7 partOf?: string
8 next?: string
9 first?: string
10}
diff --git a/packages/models/src/activitypub/activitypub-root.ts b/packages/models/src/activitypub/activitypub-root.ts
new file mode 100644
index 000000000..2fa1970c7
--- /dev/null
+++ b/packages/models/src/activitypub/activitypub-root.ts
@@ -0,0 +1,5 @@
1import { Activity } from './activity.js'
2import { ActivityPubCollection } from './activitypub-collection.js'
3import { ActivityPubOrderedCollection } from './activitypub-ordered-collection.js'
4
5export type RootActivity = Activity | ActivityPubCollection | ActivityPubOrderedCollection<Activity>
diff --git a/packages/models/src/activitypub/activitypub-signature.ts b/packages/models/src/activitypub/activitypub-signature.ts
new file mode 100644
index 000000000..fafdc246d
--- /dev/null
+++ b/packages/models/src/activitypub/activitypub-signature.ts
@@ -0,0 +1,6 @@
1export interface ActivityPubSignature {
2 type: string
3 created: Date
4 creator: string
5 signatureValue: string
6}
diff --git a/packages/models/src/activitypub/context.ts b/packages/models/src/activitypub/context.ts
new file mode 100644
index 000000000..e9df38207
--- /dev/null
+++ b/packages/models/src/activitypub/context.ts
@@ -0,0 +1,16 @@
1export type ContextType =
2 'Video' |
3 'Comment' |
4 'Playlist' |
5 'Follow' |
6 'Reject' |
7 'Accept' |
8 'View' |
9 'Announce' |
10 'CacheFile' |
11 'Delete' |
12 'Rate' |
13 'Flag' |
14 'Actor' |
15 'Collection' |
16 'WatchAction'
diff --git a/packages/models/src/activitypub/index.ts b/packages/models/src/activitypub/index.ts
new file mode 100644
index 000000000..f36aa1bc5
--- /dev/null
+++ b/packages/models/src/activitypub/index.ts
@@ -0,0 +1,9 @@
1export * from './objects/index.js'
2export * from './activity.js'
3export * from './activitypub-actor.js'
4export * from './activitypub-collection.js'
5export * from './activitypub-ordered-collection.js'
6export * from './activitypub-root.js'
7export * from './activitypub-signature.js'
8export * from './context.js'
9export * from './webfinger.js'
diff --git a/packages/models/src/activitypub/objects/abuse-object.ts b/packages/models/src/activitypub/objects/abuse-object.ts
new file mode 100644
index 000000000..2c0f2832b
--- /dev/null
+++ b/packages/models/src/activitypub/objects/abuse-object.ts
@@ -0,0 +1,15 @@
1import { ActivityFlagReasonObject } from './common-objects.js'
2
3export interface AbuseObject {
4 type: 'Flag'
5
6 content: string
7 mediaType: 'text/markdown'
8
9 object: string | string[]
10
11 tag?: ActivityFlagReasonObject[]
12
13 startAt?: number
14 endAt?: number
15}
diff --git a/packages/models/src/activitypub/objects/activitypub-object.ts b/packages/models/src/activitypub/objects/activitypub-object.ts
new file mode 100644
index 000000000..93c925ae0
--- /dev/null
+++ b/packages/models/src/activitypub/objects/activitypub-object.ts
@@ -0,0 +1,17 @@
1import { AbuseObject } from './abuse-object.js'
2import { CacheFileObject } from './cache-file-object.js'
3import { PlaylistObject } from './playlist-object.js'
4import { VideoCommentObject } from './video-comment-object.js'
5import { VideoObject } from './video-object.js'
6import { WatchActionObject } from './watch-action-object.js'
7
8export type ActivityObject =
9 VideoObject |
10 AbuseObject |
11 VideoCommentObject |
12 CacheFileObject |
13 PlaylistObject |
14 WatchActionObject |
15 string
16
17export type APObjectId = string | { id: string }
diff --git a/packages/models/src/activitypub/objects/cache-file-object.ts b/packages/models/src/activitypub/objects/cache-file-object.ts
new file mode 100644
index 000000000..a40ef339c
--- /dev/null
+++ b/packages/models/src/activitypub/objects/cache-file-object.ts
@@ -0,0 +1,9 @@
1import { ActivityVideoUrlObject, ActivityPlaylistUrlObject } from './common-objects.js'
2
3export interface CacheFileObject {
4 id: string
5 type: 'CacheFile'
6 object: string
7 expires: string
8 url: ActivityVideoUrlObject | ActivityPlaylistUrlObject
9}
diff --git a/packages/models/src/activitypub/objects/common-objects.ts b/packages/models/src/activitypub/objects/common-objects.ts
new file mode 100644
index 000000000..a332c26f3
--- /dev/null
+++ b/packages/models/src/activitypub/objects/common-objects.ts
@@ -0,0 +1,130 @@
1import { AbusePredefinedReasonsString } from '../../moderation/abuse/abuse-reason.model.js'
2
3export interface ActivityIdentifierObject {
4 identifier: string
5 name: string
6 url?: string
7}
8
9export interface ActivityIconObject {
10 type: 'Image'
11 url: string
12 mediaType: string
13 width?: number
14 height?: number
15}
16
17export type ActivityVideoUrlObject = {
18 type: 'Link'
19 mediaType: 'video/mp4' | 'video/webm' | 'video/ogg'
20 href: string
21 height: number
22 size: number
23 fps: number
24}
25
26export type ActivityPlaylistSegmentHashesObject = {
27 type: 'Link'
28 name: 'sha256'
29 mediaType: 'application/json'
30 href: string
31}
32
33export type ActivityVideoFileMetadataUrlObject = {
34 type: 'Link'
35 rel: [ 'metadata', any ]
36 mediaType: 'application/json'
37 height: number
38 href: string
39 fps: number
40}
41
42export type ActivityTrackerUrlObject = {
43 type: 'Link'
44 rel: [ 'tracker', 'websocket' | 'http' ]
45 name: string
46 href: string
47}
48
49export type ActivityStreamingPlaylistInfohashesObject = {
50 type: 'Infohash'
51 name: string
52}
53
54export type ActivityPlaylistUrlObject = {
55 type: 'Link'
56 mediaType: 'application/x-mpegURL'
57 href: string
58 tag?: ActivityTagObject[]
59}
60
61export type ActivityBitTorrentUrlObject = {
62 type: 'Link'
63 mediaType: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet'
64 href: string
65 height: number
66}
67
68export type ActivityMagnetUrlObject = {
69 type: 'Link'
70 mediaType: 'application/x-bittorrent;x-scheme-handler/magnet'
71 href: string
72 height: number
73}
74
75export type ActivityHtmlUrlObject = {
76 type: 'Link'
77 mediaType: 'text/html'
78 href: string
79}
80
81export interface ActivityHashTagObject {
82 type: 'Hashtag'
83 href?: string
84 name: string
85}
86
87export interface ActivityMentionObject {
88 type: 'Mention'
89 href?: string
90 name: string
91}
92
93export interface ActivityFlagReasonObject {
94 type: 'Hashtag'
95 name: AbusePredefinedReasonsString
96}
97
98export type ActivityTagObject =
99 ActivityPlaylistSegmentHashesObject
100 | ActivityStreamingPlaylistInfohashesObject
101 | ActivityVideoUrlObject
102 | ActivityHashTagObject
103 | ActivityMentionObject
104 | ActivityBitTorrentUrlObject
105 | ActivityMagnetUrlObject
106 | ActivityVideoFileMetadataUrlObject
107
108export type ActivityUrlObject =
109 ActivityVideoUrlObject
110 | ActivityPlaylistUrlObject
111 | ActivityBitTorrentUrlObject
112 | ActivityMagnetUrlObject
113 | ActivityHtmlUrlObject
114 | ActivityVideoFileMetadataUrlObject
115 | ActivityTrackerUrlObject
116
117export type ActivityPubAttributedTo = { type: 'Group' | 'Person', id: string } | string
118
119export interface ActivityTombstoneObject {
120 '@context'?: any
121 id: string
122 url?: string
123 type: 'Tombstone'
124 name?: string
125 formerType?: string
126 inReplyTo?: string
127 published: string
128 updated: string
129 deleted: string
130}
diff --git a/packages/models/src/activitypub/objects/index.ts b/packages/models/src/activitypub/objects/index.ts
new file mode 100644
index 000000000..510f621ea
--- /dev/null
+++ b/packages/models/src/activitypub/objects/index.ts
@@ -0,0 +1,9 @@
1export * from './abuse-object.js'
2export * from './activitypub-object.js'
3export * from './cache-file-object.js'
4export * from './common-objects.js'
5export * from './playlist-element-object.js'
6export * from './playlist-object.js'
7export * from './video-comment-object.js'
8export * from './video-object.js'
9export * from './watch-action-object.js'
diff --git a/packages/models/src/activitypub/objects/playlist-element-object.ts b/packages/models/src/activitypub/objects/playlist-element-object.ts
new file mode 100644
index 000000000..b85e4fe19
--- /dev/null
+++ b/packages/models/src/activitypub/objects/playlist-element-object.ts
@@ -0,0 +1,10 @@
1export interface PlaylistElementObject {
2 id: string
3 type: 'PlaylistElement'
4
5 url: string
6 position: number
7
8 startTimestamp?: number
9 stopTimestamp?: number
10}
diff --git a/packages/models/src/activitypub/objects/playlist-object.ts b/packages/models/src/activitypub/objects/playlist-object.ts
new file mode 100644
index 000000000..c68a28780
--- /dev/null
+++ b/packages/models/src/activitypub/objects/playlist-object.ts
@@ -0,0 +1,29 @@
1import { ActivityIconObject, ActivityPubAttributedTo } from './common-objects.js'
2
3export interface PlaylistObject {
4 id: string
5 type: 'Playlist'
6
7 name: string
8
9 content: string
10 mediaType: 'text/markdown'
11
12 uuid: string
13
14 totalItems: number
15 attributedTo: ActivityPubAttributedTo[]
16
17 icon?: ActivityIconObject
18
19 published: string
20 updated: string
21
22 orderedItems?: string[]
23
24 partOf?: string
25 next?: string
26 first?: string
27
28 to?: string[]
29}
diff --git a/packages/models/src/activitypub/objects/video-comment-object.ts b/packages/models/src/activitypub/objects/video-comment-object.ts
new file mode 100644
index 000000000..880dd2ee2
--- /dev/null
+++ b/packages/models/src/activitypub/objects/video-comment-object.ts
@@ -0,0 +1,16 @@
1import { ActivityPubAttributedTo, ActivityTagObject } from './common-objects.js'
2
3export interface VideoCommentObject {
4 type: 'Note'
5 id: string
6
7 content: string
8 mediaType: 'text/markdown'
9
10 inReplyTo: string
11 published: string
12 updated: string
13 url: string
14 attributedTo: ActivityPubAttributedTo
15 tag: ActivityTagObject[]
16}
diff --git a/packages/models/src/activitypub/objects/video-object.ts b/packages/models/src/activitypub/objects/video-object.ts
new file mode 100644
index 000000000..14afd85a2
--- /dev/null
+++ b/packages/models/src/activitypub/objects/video-object.ts
@@ -0,0 +1,74 @@
1import { LiveVideoLatencyModeType, VideoStateType } from '../../videos/index.js'
2import {
3 ActivityIconObject,
4 ActivityIdentifierObject,
5 ActivityPubAttributedTo,
6 ActivityTagObject,
7 ActivityUrlObject
8} from './common-objects.js'
9
10export interface VideoObject {
11 type: 'Video'
12 id: string
13 name: string
14 duration: string
15 uuid: string
16 tag: ActivityTagObject[]
17 category: ActivityIdentifierObject
18 licence: ActivityIdentifierObject
19 language: ActivityIdentifierObject
20 subtitleLanguage: ActivityIdentifierObject[]
21 views: number
22
23 sensitive: boolean
24
25 isLiveBroadcast: boolean
26 liveSaveReplay: boolean
27 permanentLive: boolean
28 latencyMode: LiveVideoLatencyModeType
29
30 commentsEnabled: boolean
31 downloadEnabled: boolean
32 waitTranscoding: boolean
33 state: VideoStateType
34
35 published: string
36 originallyPublishedAt: string
37 updated: string
38 uploadDate: string
39
40 mediaType: 'text/markdown'
41 content: string
42
43 support: string
44
45 icon: ActivityIconObject[]
46
47 url: ActivityUrlObject[]
48
49 likes: string
50 dislikes: string
51 shares: string
52 comments: string
53
54 attributedTo: ActivityPubAttributedTo[]
55
56 preview?: ActivityPubStoryboard[]
57
58 to?: string[]
59 cc?: string[]
60}
61
62export interface ActivityPubStoryboard {
63 type: 'Image'
64 rel: [ 'storyboard' ]
65 url: {
66 href: string
67 mediaType: string
68 width: number
69 height: number
70 tileWidth: number
71 tileHeight: number
72 tileDuration: string
73 }[]
74}
diff --git a/packages/models/src/activitypub/objects/watch-action-object.ts b/packages/models/src/activitypub/objects/watch-action-object.ts
new file mode 100644
index 000000000..ed336602f
--- /dev/null
+++ b/packages/models/src/activitypub/objects/watch-action-object.ts
@@ -0,0 +1,22 @@
1export interface WatchActionObject {
2 id: string
3 type: 'WatchAction'
4
5 startTime: string
6 endTime: string
7
8 location?: {
9 addressCountry: string
10 }
11
12 uuid: string
13 object: string
14 actionStatus: 'CompletedActionStatus'
15
16 duration: string
17
18 watchSections: {
19 startTimestamp: number
20 endTimestamp: number
21 }[]
22}
diff --git a/packages/models/src/activitypub/webfinger.ts b/packages/models/src/activitypub/webfinger.ts
new file mode 100644
index 000000000..b94baf996
--- /dev/null
+++ b/packages/models/src/activitypub/webfinger.ts
@@ -0,0 +1,9 @@
1export interface WebFingerData {
2 subject: string
3 aliases: string[]
4 links: {
5 rel: 'self'
6 type: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
7 href: string
8 }[]
9}