]>
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, | |
5f189c9c C |
8 | // Filter the result of the get function |
9 | // Used to get detailed video information (video watch page for example) | |
7663e55a | 10 | 'filter:api.video.get.result': true, |
b4055e1c | 11 | |
2158ac90 | 12 | // Filter the result of the accept upload, import via torrent or url functions |
5f189c9c | 13 | // If this function returns false then the upload is aborted with an error |
7663e55a | 14 | 'filter:api.video.upload.accept.result': true, |
2158ac90 RK |
15 | 'filter:api.video.pre-import-url.accept.result': true, |
16 | 'filter:api.video.pre-import-torrent.accept.result': true, | |
17 | 'filter:api.video.post-import-url.accept.result': true, | |
18 | 'filter:api.video.post-import-torrent.accept.result': true, | |
5f189c9c C |
19 | // Filter the result of the accept comment (thread or reply) functions |
20 | // If the functions return false then the user cannot post its comment | |
7663e55a C |
21 | 'filter:api.video-thread.create.accept.result': true, |
22 | 'filter:api.video-comment-reply.create.accept.result': true, | |
b4055e1c | 23 | |
5f189c9c C |
24 | // Filter params/result used to list threads of a specific video |
25 | // (used by the video watch page) | |
7663e55a C |
26 | 'filter:api.video-threads.list.params': true, |
27 | 'filter:api.video-threads.list.result': true, | |
b4055e1c | 28 | |
5f189c9c C |
29 | // Filter params/result used to list replies of a specific thread |
30 | // (used by the video watch page when we click on the "View replies" button) | |
7663e55a C |
31 | 'filter:api.video-thread-comments.list.params': true, |
32 | 'filter:api.video-thread-comments.list.result': true, | |
6691c522 | 33 | |
5f189c9c C |
34 | // Filter result used to check if we need to auto blacklist a video |
35 | // (fired when a local or remote video is created or updated) | |
4ce7eb71 C |
36 | 'filter:video.auto-blacklist.result': true, |
37 | ||
38 | // Filter result used to check if a user can register on the instance | |
39 | 'filter:api.user.signup.allowed.result': true | |
7663e55a C |
40 | } |
41 | ||
42 | export type ServerFilterHookName = keyof typeof serverFilterHookObject | |
b4055e1c | 43 | |
7663e55a | 44 | export const serverActionHookObject = { |
5f189c9c | 45 | // Fired when the application has been loaded and is listening HTTP requests |
7663e55a | 46 | 'action:application.listening': true, |
b4055e1c | 47 | |
5f189c9c | 48 | // Fired when a local video is updated |
7663e55a | 49 | 'action:api.video.updated': true, |
5f189c9c | 50 | // Fired when a local video is deleted |
7663e55a | 51 | 'action:api.video.deleted': true, |
5f189c9c | 52 | // Fired when a local video is uploaded |
7663e55a | 53 | 'action:api.video.uploaded': true, |
5f189c9c | 54 | // Fired when a local video is viewed |
7663e55a C |
55 | 'action:api.video.viewed': true, |
56 | ||
5f189c9c | 57 | // Fired when a thread is created |
7663e55a | 58 | 'action:api.video-thread.created': true, |
5f189c9c | 59 | // Fired when a reply to a thread is created |
7663e55a | 60 | 'action:api.video-comment-reply.created': true, |
5f189c9c | 61 | // Fired when a comment (thread or reply) is deleted |
6f3fe96f C |
62 | 'action:api.video-comment.deleted': true, |
63 | ||
64 | // Fired when a user is blocked (banned) | |
65 | 'action:api.user.blocked': true, | |
66 | // Fired when a user is unblocked (unbanned) | |
67 | 'action:api.user.unblocked': true, | |
68 | // Fired when a user registered on the instance | |
69 | 'action:api.user.registered': true, | |
70 | // Fired when an admin/moderator created a user | |
71 | 'action:api.user.created': true, | |
72 | // Fired when a user is removed by an admin/moderator | |
73 | 'action:api.user.deleted': true, | |
74 | // Fired when a user is updated by an admin/moderator | |
75 | 'action:api.user.updated': true, | |
76 | ||
a1587156 | 77 | // Fired when a user got a new oauth2 token |
6f3fe96f | 78 | 'action:api.user.oauth2-got-token': true |
7663e55a | 79 | } |
b4055e1c | 80 | |
7663e55a | 81 | export type ServerActionHookName = keyof typeof serverActionHookObject |
b4055e1c | 82 | |
7663e55a C |
83 | export const serverHookObject = Object.assign({}, serverFilterHookObject, serverActionHookObject) |
84 | export type ServerHookName = keyof typeof serverHookObject | |
b4055e1c C |
85 | |
86 | export interface ServerHook { | |
93cae479 | 87 | runHook <T> (hookName: ServerHookName, result?: T, params?: any): Promise<T> |
b4055e1c | 88 | } |