]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/models/plugins/server-hook.model.ts
Add live server hooks
[github/Chocobozzz/PeerTube.git] / shared / models / plugins / server-hook.model.ts
1 // {hookType}:{api?}.{location}.{subLocation?}.{actionType}.{target}
2
3 export const serverFilterHookObject = {
4 // Filter params/result used to list videos for the REST API
5 // (used by the trending page, recently-added page, local page etc)
6 'filter:api.videos.list.params': true,
7 'filter:api.videos.list.result': true,
8 // Filter the result of the get function
9 // Used to get detailed video information (video watch page for example)
10 'filter:api.video.get.result': true,
11
12 // Filter the result of the accept upload/live, import via torrent/url functions
13 // If this function returns false then the upload is aborted with an error
14 'filter:api.video.upload.accept.result': true,
15 'filter:api.live-video.create.accept.result': true,
16 'filter:api.video.pre-import-url.accept.result': true,
17 'filter:api.video.pre-import-torrent.accept.result': true,
18 'filter:api.video.post-import-url.accept.result': true,
19 'filter:api.video.post-import-torrent.accept.result': true,
20 // Filter the result of the accept comment (thread or reply) functions
21 // If the functions return false then the user cannot post its comment
22 'filter:api.video-thread.create.accept.result': true,
23 'filter:api.video-comment-reply.create.accept.result': true,
24
25 // Filter params/result used to list threads of a specific video
26 // (used by the video watch page)
27 'filter:api.video-threads.list.params': true,
28 'filter:api.video-threads.list.result': true,
29
30 // Filter params/result used to list replies of a specific thread
31 // (used by the video watch page when we click on the "View replies" button)
32 'filter:api.video-thread-comments.list.params': true,
33 'filter:api.video-thread-comments.list.result': true,
34
35 // Filter result used to check if we need to auto blacklist a video
36 // (fired when a local or remote video is created or updated)
37 'filter:video.auto-blacklist.result': true,
38
39 // Filter result used to check if a user can register on the instance
40 'filter:api.user.signup.allowed.result': true
41 }
42
43 export type ServerFilterHookName = keyof typeof serverFilterHookObject
44
45 export const serverActionHookObject = {
46 // Fired when the application has been loaded and is listening HTTP requests
47 'action:application.listening': true,
48
49 // Fired when a local video is updated
50 'action:api.video.updated': true,
51 // Fired when a local video is deleted
52 'action:api.video.deleted': true,
53 // Fired when a local video is uploaded
54 'action:api.video.uploaded': true,
55 // Fired when a local video is viewed
56 'action:api.video.viewed': true,
57
58 // Fired when a live video is created
59 'action:api.live-video.created': true,
60
61 // Fired when a thread is created
62 'action:api.video-thread.created': true,
63 // Fired when a reply to a thread is created
64 'action:api.video-comment-reply.created': true,
65 // Fired when a comment (thread or reply) is deleted
66 'action:api.video-comment.deleted': true,
67
68 // Fired when a user is blocked (banned)
69 'action:api.user.blocked': true,
70 // Fired when a user is unblocked (unbanned)
71 'action:api.user.unblocked': true,
72 // Fired when a user registered on the instance
73 'action:api.user.registered': true,
74 // Fired when an admin/moderator created a user
75 'action:api.user.created': true,
76 // Fired when a user is removed by an admin/moderator
77 'action:api.user.deleted': true,
78 // Fired when a user is updated by an admin/moderator
79 'action:api.user.updated': true,
80
81 // Fired when a user got a new oauth2 token
82 'action:api.user.oauth2-got-token': true
83 }
84
85 export type ServerActionHookName = keyof typeof serverActionHookObject
86
87 export const serverHookObject = Object.assign({}, serverFilterHookObject, serverActionHookObject)
88 export type ServerHookName = keyof typeof serverHookObject
89
90 export interface ServerHook {
91 runHook <T> (hookName: ServerHookName, result?: T, params?: any): Promise<T>
92 }