]>
Commit | Line | Data |
---|---|---|
a8b666e9 C |
1 | // {hookType}:{api?}.{location}.{subLocation?}.{actionType}.{target} |
2 | ||
7663e55a | 3 | export 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 | ||
74a4d531 C |
30 | // Filter params/results to search videos/channels in the DB or on the remote index |
31 | 'filter:api.search.videos.local.list.params': true, | |
32 | 'filter:api.search.videos.local.list.result': true, | |
33 | 'filter:api.search.videos.index.list.params': true, | |
34 | 'filter:api.search.videos.index.list.result': true, | |
35 | 'filter:api.search.video-channels.local.list.params': true, | |
36 | 'filter:api.search.video-channels.local.list.result': true, | |
37 | 'filter:api.search.video-channels.index.list.params': true, | |
38 | 'filter:api.search.video-channels.index.list.result': true, | |
37a44fc9 C |
39 | 'filter:api.search.video-playlists.local.list.params': true, |
40 | 'filter:api.search.video-playlists.local.list.result': true, | |
41 | 'filter:api.search.video-playlists.index.list.params': true, | |
42 | 'filter:api.search.video-playlists.index.list.result': true, | |
74a4d531 | 43 | |
5f189c9c C |
44 | // Filter the result of the get function |
45 | // Used to get detailed video information (video watch page for example) | |
7663e55a | 46 | 'filter:api.video.get.result': true, |
b4055e1c | 47 | |
3cabf353 | 48 | // Filter the result of the accept upload/live, import via torrent/url functions |
5f189c9c | 49 | // If this function returns false then the upload is aborted with an error |
7663e55a | 50 | 'filter:api.video.upload.accept.result': true, |
3cabf353 | 51 | 'filter:api.live-video.create.accept.result': true, |
2158ac90 RK |
52 | 'filter:api.video.pre-import-url.accept.result': true, |
53 | 'filter:api.video.pre-import-torrent.accept.result': true, | |
54 | 'filter:api.video.post-import-url.accept.result': true, | |
55 | 'filter:api.video.post-import-torrent.accept.result': true, | |
5f189c9c C |
56 | // Filter the result of the accept comment (thread or reply) functions |
57 | // If the functions return false then the user cannot post its comment | |
7663e55a C |
58 | 'filter:api.video-thread.create.accept.result': true, |
59 | 'filter:api.video-comment-reply.create.accept.result': true, | |
b4055e1c | 60 | |
d17d7430 C |
61 | // Filter attributes when creating video object |
62 | 'filter:api.video.upload.video-attribute.result': true, | |
63 | 'filter:api.video.import-url.video-attribute.result': true, | |
64 | 'filter:api.video.import-torrent.video-attribute.result': true, | |
65 | 'filter:api.video.live.video-attribute.result': true, | |
66 | ||
5f189c9c C |
67 | // Filter params/result used to list threads of a specific video |
68 | // (used by the video watch page) | |
7663e55a C |
69 | 'filter:api.video-threads.list.params': true, |
70 | 'filter:api.video-threads.list.result': true, | |
b4055e1c | 71 | |
5f189c9c C |
72 | // Filter params/result used to list replies of a specific thread |
73 | // (used by the video watch page when we click on the "View replies" button) | |
7663e55a C |
74 | 'filter:api.video-thread-comments.list.params': true, |
75 | 'filter:api.video-thread-comments.list.result': true, | |
6691c522 | 76 | |
65058050 C |
77 | // Filter get stats result |
78 | 'filter:api.server.stats.get.result': true, | |
79 | ||
5f189c9c C |
80 | // Filter result used to check if we need to auto blacklist a video |
81 | // (fired when a local or remote video is created or updated) | |
4ce7eb71 C |
82 | 'filter:video.auto-blacklist.result': true, |
83 | ||
84 | // Filter result used to check if a user can register on the instance | |
4bc45da3 C |
85 | 'filter:api.user.signup.allowed.result': true, |
86 | ||
87 | // Filter result used to check if video/torrent download is allowed | |
88 | 'filter:api.download.video.allowed.result': true, | |
eebd9838 C |
89 | 'filter:api.download.torrent.allowed.result': true, |
90 | ||
91 | // Filter result to check if the embed is allowed for a particular request | |
92 | 'filter:html.embed.video.allowed.result': true, | |
93 | 'filter:html.embed.video-playlist.allowed.result': true | |
7663e55a C |
94 | } |
95 | ||
96 | export type ServerFilterHookName = keyof typeof serverFilterHookObject | |
b4055e1c | 97 | |
7663e55a | 98 | export const serverActionHookObject = { |
5f189c9c | 99 | // Fired when the application has been loaded and is listening HTTP requests |
7663e55a | 100 | 'action:application.listening': true, |
b4055e1c | 101 | |
7226e90f | 102 | // API actions hooks give access to the original express `req` and `res` parameters |
103 | ||
5f189c9c | 104 | // Fired when a local video is updated |
7663e55a | 105 | 'action:api.video.updated': true, |
5f189c9c | 106 | // Fired when a local video is deleted |
7663e55a | 107 | 'action:api.video.deleted': true, |
5f189c9c | 108 | // Fired when a local video is uploaded |
7663e55a | 109 | 'action:api.video.uploaded': true, |
5f189c9c | 110 | // Fired when a local video is viewed |
7663e55a C |
111 | 'action:api.video.viewed': true, |
112 | ||
3cabf353 C |
113 | // Fired when a live video is created |
114 | 'action:api.live-video.created': true, | |
115 | ||
5f189c9c | 116 | // Fired when a thread is created |
7663e55a | 117 | 'action:api.video-thread.created': true, |
5f189c9c | 118 | // Fired when a reply to a thread is created |
7663e55a | 119 | 'action:api.video-comment-reply.created': true, |
5f189c9c | 120 | // Fired when a comment (thread or reply) is deleted |
6f3fe96f C |
121 | 'action:api.video-comment.deleted': true, |
122 | ||
5e3d29ab | 123 | // Fired when a caption is created |
124 | 'action:api.video-caption.created': true, | |
125 | // Fired when a caption is deleted | |
126 | 'action:api.video-caption.deleted': true, | |
127 | ||
6f3fe96f C |
128 | // Fired when a user is blocked (banned) |
129 | 'action:api.user.blocked': true, | |
130 | // Fired when a user is unblocked (unbanned) | |
131 | 'action:api.user.unblocked': true, | |
132 | // Fired when a user registered on the instance | |
133 | 'action:api.user.registered': true, | |
134 | // Fired when an admin/moderator created a user | |
135 | 'action:api.user.created': true, | |
136 | // Fired when a user is removed by an admin/moderator | |
137 | 'action:api.user.deleted': true, | |
138 | // Fired when a user is updated by an admin/moderator | |
139 | 'action:api.user.updated': true, | |
140 | ||
a1587156 | 141 | // Fired when a user got a new oauth2 token |
e2e0b645 | 142 | 'action:api.user.oauth2-got-token': true, |
143 | ||
144 | // Fired when a video is added to a playlist | |
145 | 'action:api.video-playlist-element.created': true | |
7663e55a | 146 | } |
b4055e1c | 147 | |
7663e55a | 148 | export type ServerActionHookName = keyof typeof serverActionHookObject |
b4055e1c | 149 | |
7663e55a C |
150 | export const serverHookObject = Object.assign({}, serverFilterHookObject, serverActionHookObject) |
151 | export type ServerHookName = keyof typeof serverHookObject | |
b4055e1c C |
152 | |
153 | export interface ServerHook { | |
93cae479 | 154 | runHook <T> (hookName: ServerHookName, result?: T, params?: any): Promise<T> |
b4055e1c | 155 | } |