diff options
Diffstat (limited to 'shared/models/activitypub')
-rw-r--r-- | shared/models/activitypub/activity.ts | 56 | ||||
-rw-r--r-- | shared/models/activitypub/objects/activitypub-object.ts | 17 | ||||
-rw-r--r-- | shared/models/activitypub/objects/dislike-object.ts | 6 | ||||
-rw-r--r-- | shared/models/activitypub/objects/index.ts | 3 | ||||
-rw-r--r-- | shared/models/activitypub/objects/object.model.ts | 1 |
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 @@ | |||
1 | import { ActivityPubActor } from './activitypub-actor' | 1 | import { ActivityPubActor } from './activitypub-actor' |
2 | import { ActivityPubSignature } from './activitypub-signature' | 2 | import { ActivityPubSignature } from './activitypub-signature' |
3 | import { ActivityFlagReasonObject, CacheFileObject, VideoObject, WatchActionObject } from './objects' | 3 | import { |
4 | import { AbuseObject } from './objects/abuse-object' | 4 | ActivityFlagReasonObject, |
5 | import { DislikeObject } from './objects/dislike-object' | 5 | ActivityObject, |
6 | import { APObject } from './objects/object.model' | 6 | APObjectId, |
7 | import { PlaylistObject } from './objects/playlist-object' | 7 | CacheFileObject, |
8 | import { VideoCommentObject } from './objects/video-comment-object' | 8 | PlaylistObject, |
9 | VideoCommentObject, | ||
10 | VideoObject, | ||
11 | WatchActionObject | ||
12 | } from './objects' | ||
13 | |||
14 | export type ActivityUpdateObject = | ||
15 | Extract<ActivityObject, VideoObject | CacheFileObject | PlaylistObject | ActivityPubActor | string> | ActivityPubActor | ||
16 | |||
17 | // Cannot Extract from Activity because of circular reference | ||
18 | export type ActivityUndoObject = | ||
19 | ActivityFollow | ActivityLike | ActivityDislike | ActivityCreate<CacheFileObject | string> | ActivityAnnounce | ||
20 | |||
21 | export type ActivityCreateObject = | ||
22 | Extract<ActivityObject, VideoObject | CacheFileObject | WatchActionObject | VideoCommentObject | PlaylistObject | string> | ||
9 | 23 | ||
10 | export type Activity = | 24 | export 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 | ||
53 | export interface ActivityCreate extends BaseActivity { | 67 | export 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 | ||
58 | export interface ActivityUpdate extends BaseActivity { | 72 | export 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 | ||
63 | export interface ActivityDelete extends BaseActivity { | 77 | export interface ActivityDelete extends BaseActivity { |
64 | type: 'Delete' | 78 | type: 'Delete' |
65 | object: string | { id: string } | 79 | object: APObjectId |
66 | } | 80 | } |
67 | 81 | ||
68 | export interface ActivityFollow extends BaseActivity { | 82 | export interface ActivityFollow extends BaseActivity { |
@@ -82,23 +96,23 @@ export interface ActivityReject extends BaseActivity { | |||
82 | 96 | ||
83 | export interface ActivityAnnounce extends BaseActivity { | 97 | export interface ActivityAnnounce extends BaseActivity { |
84 | type: 'Announce' | 98 | type: 'Announce' |
85 | object: APObject | 99 | object: APObjectId |
86 | } | 100 | } |
87 | 101 | ||
88 | export interface ActivityUndo extends BaseActivity { | 102 | export 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 | ||
93 | export interface ActivityLike extends BaseActivity { | 107 | export interface ActivityLike extends BaseActivity { |
94 | type: 'Like' | 108 | type: 'Like' |
95 | object: APObject | 109 | object: APObjectId |
96 | } | 110 | } |
97 | 111 | ||
98 | export interface ActivityView extends BaseActivity { | 112 | export 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 | ||
114 | export interface ActivityFlag extends BaseActivity { | 128 | export 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 @@ | |||
1 | import { AbuseObject } from './abuse-object' | ||
2 | import { CacheFileObject } from './cache-file-object' | ||
3 | import { PlaylistObject } from './playlist-object' | ||
4 | import { VideoCommentObject } from './video-comment-object' | ||
5 | import { VideoObject } from './video-object' | ||
6 | import { WatchActionObject } from './watch-action-object' | ||
7 | |||
8 | export type ActivityObject = | ||
9 | VideoObject | | ||
10 | AbuseObject | | ||
11 | VideoCommentObject | | ||
12 | CacheFileObject | | ||
13 | PlaylistObject | | ||
14 | WatchActionObject | | ||
15 | string | ||
16 | |||
17 | export 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 @@ | |||
1 | export 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 @@ | |||
1 | export * from './abuse-object' | 1 | export * from './abuse-object' |
2 | export * from './activitypub-object' | ||
2 | export * from './cache-file-object' | 3 | export * from './cache-file-object' |
3 | export * from './common-objects' | 4 | export * from './common-objects' |
4 | export * from './dislike-object' | ||
5 | export * from './object.model' | ||
6 | export * from './playlist-element-object' | 5 | export * from './playlist-element-object' |
7 | export * from './playlist-object' | 6 | export * from './playlist-object' |
8 | export * from './video-comment-object' | 7 | export * 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 @@ | |||
1 | export type APObject = string | { id: string } | ||