aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/models/activitypub
diff options
context:
space:
mode:
Diffstat (limited to 'shared/models/activitypub')
-rw-r--r--shared/models/activitypub/activity.ts56
-rw-r--r--shared/models/activitypub/objects/activitypub-object.ts17
-rw-r--r--shared/models/activitypub/objects/dislike-object.ts6
-rw-r--r--shared/models/activitypub/objects/index.ts3
-rw-r--r--shared/models/activitypub/objects/object.model.ts1
5 files changed, 53 insertions, 30 deletions
diff --git a/shared/models/activitypub/activity.ts b/shared/models/activitypub/activity.ts
index fd5d38316..10cf53ead 100644
--- a/shared/models/activitypub/activity.ts
+++ b/shared/models/activitypub/activity.ts
@@ -1,20 +1,34 @@
1import { ActivityPubActor } from './activitypub-actor' 1import { ActivityPubActor } from './activitypub-actor'
2import { ActivityPubSignature } from './activitypub-signature' 2import { ActivityPubSignature } from './activitypub-signature'
3import { ActivityFlagReasonObject, CacheFileObject, VideoObject, WatchActionObject } from './objects' 3import {
4import { AbuseObject } from './objects/abuse-object' 4 ActivityFlagReasonObject,
5import { DislikeObject } from './objects/dislike-object' 5 ActivityObject,
6import { APObject } from './objects/object.model' 6 APObjectId,
7import { PlaylistObject } from './objects/playlist-object' 7 CacheFileObject,
8import { VideoCommentObject } from './objects/video-comment-object' 8 PlaylistObject,
9 VideoCommentObject,
10 VideoObject,
11 WatchActionObject
12} from './objects'
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>
9 23
10export type Activity = 24export type Activity =
11 ActivityCreate | 25 ActivityCreate<ActivityCreateObject> |
12 ActivityUpdate | 26 ActivityUpdate<ActivityUpdateObject> |
13 ActivityDelete | 27 ActivityDelete |
14 ActivityFollow | 28 ActivityFollow |
15 ActivityAccept | 29 ActivityAccept |
16 ActivityAnnounce | 30 ActivityAnnounce |
17 ActivityUndo | 31 ActivityUndo<ActivityUndoObject> |
18 ActivityLike | 32 ActivityLike |
19 ActivityReject | 33 ActivityReject |
20 ActivityView | 34 ActivityView |
@@ -50,19 +64,19 @@ export interface BaseActivity {
50 signature?: ActivityPubSignature 64 signature?: ActivityPubSignature
51} 65}
52 66
53export interface ActivityCreate extends BaseActivity { 67export interface ActivityCreate <T extends ActivityCreateObject> extends BaseActivity {
54 type: 'Create' 68 type: 'Create'
55 object: VideoObject | AbuseObject | DislikeObject | VideoCommentObject | CacheFileObject | PlaylistObject | WatchActionObject 69 object: T
56} 70}
57 71
58export interface ActivityUpdate extends BaseActivity { 72export interface ActivityUpdate <T extends ActivityUpdateObject> extends BaseActivity {
59 type: 'Update' 73 type: 'Update'
60 object: VideoObject | ActivityPubActor | CacheFileObject | PlaylistObject 74 object: T
61} 75}
62 76
63export interface ActivityDelete extends BaseActivity { 77export interface ActivityDelete extends BaseActivity {
64 type: 'Delete' 78 type: 'Delete'
65 object: string | { id: string } 79 object: APObjectId
66} 80}
67 81
68export interface ActivityFollow extends BaseActivity { 82export interface ActivityFollow extends BaseActivity {
@@ -82,23 +96,23 @@ export interface ActivityReject extends BaseActivity {
82 96
83export interface ActivityAnnounce extends BaseActivity { 97export interface ActivityAnnounce extends BaseActivity {
84 type: 'Announce' 98 type: 'Announce'
85 object: APObject 99 object: APObjectId
86} 100}
87 101
88export interface ActivityUndo extends BaseActivity { 102export interface ActivityUndo <T extends ActivityUndoObject> extends BaseActivity {
89 type: 'Undo' 103 type: 'Undo'
90 object: ActivityFollow | ActivityLike | ActivityDislike | ActivityCreate | ActivityAnnounce 104 object: T
91} 105}
92 106
93export interface ActivityLike extends BaseActivity { 107export interface ActivityLike extends BaseActivity {
94 type: 'Like' 108 type: 'Like'
95 object: APObject 109 object: APObjectId
96} 110}
97 111
98export interface ActivityView extends BaseActivity { 112export interface ActivityView extends BaseActivity {
99 type: 'View' 113 type: 'View'
100 actor: string 114 actor: string
101 object: APObject 115 object: APObjectId
102 116
103 // If sending a "viewer" event 117 // If sending a "viewer" event
104 expires?: string 118 expires?: string
@@ -108,13 +122,13 @@ export interface ActivityDislike extends BaseActivity {
108 id: string 122 id: string
109 type: 'Dislike' 123 type: 'Dislike'
110 actor: string 124 actor: string
111 object: APObject 125 object: APObjectId
112} 126}
113 127
114export interface ActivityFlag extends BaseActivity { 128export interface ActivityFlag extends BaseActivity {
115 type: 'Flag' 129 type: 'Flag'
116 content: string 130 content: string
117 object: APObject | APObject[] 131 object: APObjectId | APObjectId[]
118 tag?: ActivityFlagReasonObject[] 132 tag?: ActivityFlagReasonObject[]
119 startAt?: number 133 startAt?: number
120 endAt?: number 134 endAt?: number
diff --git a/shared/models/activitypub/objects/activitypub-object.ts b/shared/models/activitypub/objects/activitypub-object.ts
new file mode 100644
index 000000000..faeac2618
--- /dev/null
+++ b/shared/models/activitypub/objects/activitypub-object.ts
@@ -0,0 +1,17 @@
1import { AbuseObject } from './abuse-object'
2import { CacheFileObject } from './cache-file-object'
3import { PlaylistObject } from './playlist-object'
4import { VideoCommentObject } from './video-comment-object'
5import { VideoObject } from './video-object'
6import { WatchActionObject } from './watch-action-object'
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/shared/models/activitypub/objects/dislike-object.ts b/shared/models/activitypub/objects/dislike-object.ts
deleted file mode 100644
index 7218fb784..000000000
--- a/shared/models/activitypub/objects/dislike-object.ts
+++ /dev/null
@@ -1,6 +0,0 @@
1export interface DislikeObject {
2 id: string
3 type: 'Dislike'
4 actor: string
5 object: string
6}
diff --git a/shared/models/activitypub/objects/index.ts b/shared/models/activitypub/objects/index.ts
index a2e040b32..753e02003 100644
--- a/shared/models/activitypub/objects/index.ts
+++ b/shared/models/activitypub/objects/index.ts
@@ -1,8 +1,7 @@
1export * from './abuse-object' 1export * from './abuse-object'
2export * from './activitypub-object'
2export * from './cache-file-object' 3export * from './cache-file-object'
3export * from './common-objects' 4export * from './common-objects'
4export * from './dislike-object'
5export * from './object.model'
6export * from './playlist-element-object' 5export * from './playlist-element-object'
7export * from './playlist-object' 6export * from './playlist-object'
8export * from './video-comment-object' 7export * from './video-comment-object'
diff --git a/shared/models/activitypub/objects/object.model.ts b/shared/models/activitypub/objects/object.model.ts
deleted file mode 100644
index 3fd33800a..000000000
--- a/shared/models/activitypub/objects/object.model.ts
+++ /dev/null
@@ -1 +0,0 @@
1export type APObject = string | { id: string }