]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/models/plugins/server/server-hook.model.ts
More robust quota check
[github/Chocobozzz/PeerTube.git] / shared / models / plugins / server / server-hook.model.ts
CommitLineData
c3441b03 1// {hookType}:{root}.{location}.{subLocation?}.{actionType}.{target}
a8b666e9 2
7663e55a 3export const serverFilterHookObject = {
5f189c9c
C
4 // Filter params/result used to list videos for the REST API
5 // (used by the trending page, recently-added page, local page etc)
7663e55a
C
6 'filter:api.videos.list.params': true,
7 'filter:api.videos.list.result': true,
c5ca7e1e 8
9 // Filter params/result used to list a video playlists videos
10 // for the REST API
11 'filter:api.video-playlist.videos.list.params': true,
12 'filter:api.video-playlist.videos.list.result': true,
38267c0c
C
13
14 // Filter params/result used to list account videos for the REST API
15 'filter:api.accounts.videos.list.params': true,
16 'filter:api.accounts.videos.list.result': true,
17
c0481610 18 // Filter params/result used to list channel videos for the REST API
38267c0c
C
19 'filter:api.video-channels.videos.list.params': true,
20 'filter:api.video-channels.videos.list.result': true,
21
a4d2ca07
C
22 // Filter params/result used to list my user videos for the REST API
23 'filter:api.user.me.videos.list.params': true,
24 'filter:api.user.me.videos.list.result': true,
25
64f9b91d
MW
26 // Filter params/result used to list overview videos for the REST API
27 'filter:api.overviews.videos.list.params': true,
28 'filter:api.overviews.videos.list.result': true,
29
c0687c91
W
30 // Filter params/result used to list subscription videos for the REST API
31 'filter:api.user.me.subscription-videos.list.params': true,
32 'filter:api.user.me.subscription-videos.list.result': true,
33
74a4d531
C
34 // Filter params/results to search videos/channels in the DB or on the remote index
35 'filter:api.search.videos.local.list.params': true,
36 'filter:api.search.videos.local.list.result': true,
37 'filter:api.search.videos.index.list.params': true,
38 'filter:api.search.videos.index.list.result': true,
39 'filter:api.search.video-channels.local.list.params': true,
40 'filter:api.search.video-channels.local.list.result': true,
41 'filter:api.search.video-channels.index.list.params': true,
42 'filter:api.search.video-channels.index.list.result': true,
37a44fc9
C
43 'filter:api.search.video-playlists.local.list.params': true,
44 'filter:api.search.video-playlists.local.list.result': true,
45 'filter:api.search.video-playlists.index.list.params': true,
46 'filter:api.search.video-playlists.index.list.result': true,
74a4d531 47
5f189c9c
C
48 // Filter the result of the get function
49 // Used to get detailed video information (video watch page for example)
7663e55a 50 'filter:api.video.get.result': true,
b4055e1c 51
0260dc8a
C
52 // Filter params/results when listing video channels
53 'filter:api.video-channels.list.params': true,
54 'filter:api.video-channels.list.result': true,
55
56 // Filter the result when getting a video channel
57 'filter:api.video-channel.get.result': true,
58
3cabf353 59 // Filter the result of the accept upload/live, import via torrent/url functions
5f189c9c 60 // If this function returns false then the upload is aborted with an error
7663e55a 61 'filter:api.video.upload.accept.result': true,
3cabf353 62 'filter:api.live-video.create.accept.result': true,
2158ac90
RK
63 'filter:api.video.pre-import-url.accept.result': true,
64 'filter:api.video.pre-import-torrent.accept.result': true,
65 'filter:api.video.post-import-url.accept.result': true,
66 'filter:api.video.post-import-torrent.accept.result': true,
5f189c9c
C
67 // Filter the result of the accept comment (thread or reply) functions
68 // If the functions return false then the user cannot post its comment
7663e55a
C
69 'filter:api.video-thread.create.accept.result': true,
70 'filter:api.video-comment-reply.create.accept.result': true,
b4055e1c 71
d17d7430
C
72 // Filter attributes when creating video object
73 'filter:api.video.upload.video-attribute.result': true,
74 'filter:api.video.import-url.video-attribute.result': true,
75 'filter:api.video.import-torrent.video-attribute.result': true,
76 'filter:api.video.live.video-attribute.result': true,
77
5f189c9c
C
78 // Filter params/result used to list threads of a specific video
79 // (used by the video watch page)
7663e55a
C
80 'filter:api.video-threads.list.params': true,
81 'filter:api.video-threads.list.result': true,
b4055e1c 82
5f189c9c
C
83 // Filter params/result used to list replies of a specific thread
84 // (used by the video watch page when we click on the "View replies" button)
7663e55a
C
85 'filter:api.video-thread-comments.list.params': true,
86 'filter:api.video-thread-comments.list.result': true,
6691c522 87
65058050
C
88 // Filter get stats result
89 'filter:api.server.stats.get.result': true,
90
5f189c9c
C
91 // Filter result used to check if we need to auto blacklist a video
92 // (fired when a local or remote video is created or updated)
4ce7eb71
C
93 'filter:video.auto-blacklist.result': true,
94
95 // Filter result used to check if a user can register on the instance
4bc45da3
C
96 'filter:api.user.signup.allowed.result': true,
97
e364e31e
C
98 // Filter result used to check if a user can send a registration request on the instance
99 // PeerTube >= 5.1
100 'filter:api.user.request-signup.allowed.result': true,
101
4bc45da3
C
102 // Filter result used to check if video/torrent download is allowed
103 'filter:api.download.video.allowed.result': true,
eebd9838
C
104 'filter:api.download.torrent.allowed.result': true,
105
106 // Filter result to check if the embed is allowed for a particular request
107 'filter:html.embed.video.allowed.result': true,
22df69fd
C
108 'filter:html.embed.video-playlist.allowed.result': true,
109
257fa0d1 110 // Peertube >= 5.2
d91ce83d
C
111 'filter:html.client.json-ld.result': true,
112
22df69fd 113 'filter:job-queue.process.params': true,
ebb9e53a
C
114 'filter:job-queue.process.result': true,
115
64fd6158 116 'filter:transcoding.manual.resolutions-to-transcode.result': true,
b2a70e3c
C
117 'filter:transcoding.auto.resolutions-to-transcode.result': true,
118
866b5d3f
C
119 'filter:activity-pub.remote-video-comment.create.accept.result': true,
120
121 'filter:activity-pub.activity.context.build.result': true,
122
123 // Filter the result of video JSON LD builder
124 // You may also need to use filter:activity-pub.activity.context.build.result to also update JSON LD context
96d00a99 125 'filter:activity-pub.video.json-ld.build.result': true
7663e55a
C
126}
127
128export type ServerFilterHookName = keyof typeof serverFilterHookObject
b4055e1c 129
7663e55a 130export const serverActionHookObject = {
5f189c9c 131 // Fired when the application has been loaded and is listening HTTP requests
7663e55a 132 'action:application.listening': true,
b4055e1c 133
785f1897
C
134 // Fired when a new notification is created
135 'action:notifier.notification.created': true,
136
7226e90f 137 // API actions hooks give access to the original express `req` and `res` parameters
138
5f189c9c 139 // Fired when a local video is updated
7663e55a 140 'action:api.video.updated': true,
5f189c9c 141 // Fired when a local video is deleted
7663e55a 142 'action:api.video.deleted': true,
5f189c9c 143 // Fired when a local video is uploaded
7663e55a 144 'action:api.video.uploaded': true,
5f189c9c 145 // Fired when a local video is viewed
7663e55a
C
146 'action:api.video.viewed': true,
147
0260dc8a
C
148 // Fired when a video channel is created
149 'action:api.video-channel.created': true,
150 // Fired when a video channel is updated
151 'action:api.video-channel.updated': true,
152 // Fired when a video channel is deleted
153 'action:api.video-channel.deleted': true,
154
3cabf353
C
155 // Fired when a live video is created
156 'action:api.live-video.created': true,
157
5f189c9c 158 // Fired when a thread is created
7663e55a 159 'action:api.video-thread.created': true,
5f189c9c 160 // Fired when a reply to a thread is created
7663e55a 161 'action:api.video-comment-reply.created': true,
5f189c9c 162 // Fired when a comment (thread or reply) is deleted
6f3fe96f
C
163 'action:api.video-comment.deleted': true,
164
5e3d29ab 165 // Fired when a caption is created
166 'action:api.video-caption.created': true,
167 // Fired when a caption is deleted
168 'action:api.video-caption.deleted': true,
169
6f3fe96f
C
170 // Fired when a user is blocked (banned)
171 'action:api.user.blocked': true,
172 // Fired when a user is unblocked (unbanned)
173 'action:api.user.unblocked': true,
174 // Fired when a user registered on the instance
175 'action:api.user.registered': true,
e364e31e
C
176 // Fired when a user requested registration on the instance
177 // PeerTube >= 5.1
178 'action:api.user.requested-registration': true,
6f3fe96f
C
179 // Fired when an admin/moderator created a user
180 'action:api.user.created': true,
181 // Fired when a user is removed by an admin/moderator
182 'action:api.user.deleted': true,
183 // Fired when a user is updated by an admin/moderator
184 'action:api.user.updated': true,
185
a1587156 186 // Fired when a user got a new oauth2 token
e2e0b645 187 'action:api.user.oauth2-got-token': true,
188
189 // Fired when a video is added to a playlist
c3441b03
C
190 'action:api.video-playlist-element.created': true,
191
192 // Fired when a remote video has been created/updated
193 'action:activity-pub.remote-video.created': true,
194 'action:activity-pub.remote-video.updated': true
7663e55a 195}
b4055e1c 196
7663e55a 197export type ServerActionHookName = keyof typeof serverActionHookObject
b4055e1c 198
7663e55a
C
199export const serverHookObject = Object.assign({}, serverFilterHookObject, serverActionHookObject)
200export type ServerHookName = keyof typeof serverHookObject
b4055e1c
C
201
202export interface ServerHook {
93cae479 203 runHook <T> (hookName: ServerHookName, result?: T, params?: any): Promise<T>
b4055e1c 204}