Merge branch 'release/1.4.0' into develop
[oweals/peertube.git] / shared / models / activitypub / activity.ts
1 import { ActivityPubActor } from './activitypub-actor'
2 import { ActivityPubSignature } from './activitypub-signature'
3 import { CacheFileObject, VideoTorrentObject } from './objects'
4 import { DislikeObject } from './objects/dislike-object'
5 import { VideoAbuseObject } from './objects/video-abuse-object'
6 import { VideoCommentObject } from './objects/video-comment-object'
7 import { ViewObject } from './objects/view-object'
8 import { APObject } from './objects/object.model'
9 import { PlaylistObject } from './objects/playlist-object'
10
11 export type Activity = ActivityCreate | ActivityUpdate |
12   ActivityDelete | ActivityFollow | ActivityAccept | ActivityAnnounce |
13   ActivityUndo | ActivityLike | ActivityReject | ActivityView | ActivityDislike | ActivityFlag
14
15 export type ActivityType = 'Create' | 'Update' | 'Delete' | 'Follow' | 'Accept' | 'Announce' | 'Undo' | 'Like' | 'Reject' |
16   'View' | 'Dislike' | 'Flag'
17
18 export interface ActivityAudience {
19   to: string[]
20   cc: string[]
21 }
22
23 export interface BaseActivity {
24   '@context'?: any[]
25   id: string
26   to?: string[]
27   cc?: string[]
28   actor: string | ActivityPubActor
29   type: ActivityType
30   signature?: ActivityPubSignature
31 }
32
33 export interface ActivityCreate extends BaseActivity {
34   type: 'Create'
35   object: VideoTorrentObject | VideoAbuseObject | ViewObject | DislikeObject | VideoCommentObject | CacheFileObject | PlaylistObject
36 }
37
38 export interface ActivityUpdate extends BaseActivity {
39   type: 'Update'
40   object: VideoTorrentObject | ActivityPubActor | CacheFileObject | PlaylistObject
41 }
42
43 export interface ActivityDelete extends BaseActivity {
44   type: 'Delete'
45   object: string | { id: string }
46 }
47
48 export interface ActivityFollow extends BaseActivity {
49   type: 'Follow'
50   object: string
51 }
52
53 export interface ActivityAccept extends BaseActivity {
54   type: 'Accept'
55   object: ActivityFollow
56 }
57
58 export interface ActivityReject extends BaseActivity {
59   type: 'Reject'
60   object: ActivityFollow
61 }
62
63 export interface ActivityAnnounce extends BaseActivity {
64   type: 'Announce'
65   object: APObject
66 }
67
68 export interface ActivityUndo extends BaseActivity {
69   type: 'Undo',
70   object: ActivityFollow | ActivityLike | ActivityDislike | ActivityCreate | ActivityAnnounce
71 }
72
73 export interface ActivityLike extends BaseActivity {
74   type: 'Like',
75   object: APObject
76 }
77
78 export interface ActivityView extends BaseActivity {
79   type: 'View',
80   actor: string
81   object: APObject
82 }
83
84 export interface ActivityDislike extends BaseActivity {
85   id: string
86   type: 'Dislike'
87   actor: string
88   object: APObject
89 }
90
91 export interface ActivityFlag extends BaseActivity {
92   type: 'Flag',
93   content: string,
94   object: APObject | APObject[]
95 }