]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/models/plugins/server/server-hook.model.ts
Add filter on search results
[github/Chocobozzz/PeerTube.git] / shared / models / plugins / server / server-hook.model.ts
CommitLineData
a8b666e9
C
1// {hookType}:{api?}.{location}.{subLocation?}.{actionType}.{target}
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,
38267c0c
C
8
9 // Filter params/result used to list account videos for the REST API
10 'filter:api.accounts.videos.list.params': true,
11 'filter:api.accounts.videos.list.result': true,
12
c0481610 13 // Filter params/result used to list channel videos for the REST API
38267c0c
C
14 'filter:api.video-channels.videos.list.params': true,
15 'filter:api.video-channels.videos.list.result': true,
16
a4d2ca07
C
17 // Filter params/result used to list my user videos for the REST API
18 'filter:api.user.me.videos.list.params': true,
19 'filter:api.user.me.videos.list.result': true,
20
64f9b91d
MW
21 // Filter params/result used to list overview videos for the REST API
22 'filter:api.overviews.videos.list.params': true,
23 'filter:api.overviews.videos.list.result': true,
24
74a4d531
C
25 // Filter params/results to search videos/channels in the DB or on the remote index
26 'filter:api.search.videos.local.list.params': true,
27 'filter:api.search.videos.local.list.result': true,
28 'filter:api.search.videos.index.list.params': true,
29 'filter:api.search.videos.index.list.result': true,
30 'filter:api.search.video-channels.local.list.params': true,
31 'filter:api.search.video-channels.local.list.result': true,
32 'filter:api.search.video-channels.index.list.params': true,
33 'filter:api.search.video-channels.index.list.result': true,
37a44fc9
C
34 'filter:api.search.video-playlists.local.list.params': true,
35 'filter:api.search.video-playlists.local.list.result': true,
36 'filter:api.search.video-playlists.index.list.params': true,
37 'filter:api.search.video-playlists.index.list.result': true,
74a4d531 38
5f189c9c
C
39 // Filter the result of the get function
40 // Used to get detailed video information (video watch page for example)
7663e55a 41 'filter:api.video.get.result': true,
b4055e1c 42
3cabf353 43 // Filter the result of the accept upload/live, import via torrent/url functions
5f189c9c 44 // If this function returns false then the upload is aborted with an error
7663e55a 45 'filter:api.video.upload.accept.result': true,
3cabf353 46 'filter:api.live-video.create.accept.result': true,
2158ac90
RK
47 'filter:api.video.pre-import-url.accept.result': true,
48 'filter:api.video.pre-import-torrent.accept.result': true,
49 'filter:api.video.post-import-url.accept.result': true,
50 'filter:api.video.post-import-torrent.accept.result': true,
5f189c9c
C
51 // Filter the result of the accept comment (thread or reply) functions
52 // If the functions return false then the user cannot post its comment
7663e55a
C
53 'filter:api.video-thread.create.accept.result': true,
54 'filter:api.video-comment-reply.create.accept.result': true,
b4055e1c 55
5f189c9c
C
56 // Filter params/result used to list threads of a specific video
57 // (used by the video watch page)
7663e55a
C
58 'filter:api.video-threads.list.params': true,
59 'filter:api.video-threads.list.result': true,
b4055e1c 60
5f189c9c
C
61 // Filter params/result used to list replies of a specific thread
62 // (used by the video watch page when we click on the "View replies" button)
7663e55a
C
63 'filter:api.video-thread-comments.list.params': true,
64 'filter:api.video-thread-comments.list.result': true,
6691c522 65
65058050
C
66 // Filter get stats result
67 'filter:api.server.stats.get.result': true,
68
5f189c9c
C
69 // Filter result used to check if we need to auto blacklist a video
70 // (fired when a local or remote video is created or updated)
4ce7eb71
C
71 'filter:video.auto-blacklist.result': true,
72
73 // Filter result used to check if a user can register on the instance
4bc45da3
C
74 'filter:api.user.signup.allowed.result': true,
75
76 // Filter result used to check if video/torrent download is allowed
77 'filter:api.download.video.allowed.result': true,
eebd9838
C
78 'filter:api.download.torrent.allowed.result': true,
79
80 // Filter result to check if the embed is allowed for a particular request
81 'filter:html.embed.video.allowed.result': true,
82 'filter:html.embed.video-playlist.allowed.result': true
7663e55a
C
83}
84
85export type ServerFilterHookName = keyof typeof serverFilterHookObject
b4055e1c 86
7663e55a 87export const serverActionHookObject = {
5f189c9c 88 // Fired when the application has been loaded and is listening HTTP requests
7663e55a 89 'action:application.listening': true,
b4055e1c 90
7226e90f 91 // API actions hooks give access to the original express `req` and `res` parameters
92
5f189c9c 93 // Fired when a local video is updated
7663e55a 94 'action:api.video.updated': true,
5f189c9c 95 // Fired when a local video is deleted
7663e55a 96 'action:api.video.deleted': true,
5f189c9c 97 // Fired when a local video is uploaded
7663e55a 98 'action:api.video.uploaded': true,
5f189c9c 99 // Fired when a local video is viewed
7663e55a
C
100 'action:api.video.viewed': true,
101
3cabf353
C
102 // Fired when a live video is created
103 'action:api.live-video.created': true,
104
5f189c9c 105 // Fired when a thread is created
7663e55a 106 'action:api.video-thread.created': true,
5f189c9c 107 // Fired when a reply to a thread is created
7663e55a 108 'action:api.video-comment-reply.created': true,
5f189c9c 109 // Fired when a comment (thread or reply) is deleted
6f3fe96f
C
110 'action:api.video-comment.deleted': true,
111
112 // Fired when a user is blocked (banned)
113 'action:api.user.blocked': true,
114 // Fired when a user is unblocked (unbanned)
115 'action:api.user.unblocked': true,
116 // Fired when a user registered on the instance
117 'action:api.user.registered': true,
118 // Fired when an admin/moderator created a user
119 'action:api.user.created': true,
120 // Fired when a user is removed by an admin/moderator
121 'action:api.user.deleted': true,
122 // Fired when a user is updated by an admin/moderator
123 'action:api.user.updated': true,
124
a1587156 125 // Fired when a user got a new oauth2 token
e2e0b645 126 'action:api.user.oauth2-got-token': true,
127
128 // Fired when a video is added to a playlist
129 'action:api.video-playlist-element.created': true
7663e55a 130}
b4055e1c 131
7663e55a 132export type ServerActionHookName = keyof typeof serverActionHookObject
b4055e1c 133
7663e55a
C
134export const serverHookObject = Object.assign({}, serverFilterHookObject, serverActionHookObject)
135export type ServerHookName = keyof typeof serverHookObject
b4055e1c
C
136
137export interface ServerHook {
93cae479 138 runHook <T> (hookName: ServerHookName, result?: T, params?: any): Promise<T>
b4055e1c 139}