aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-24 10:21:22 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commit5f189c9c85449951254646ddf6cd6c84bc4c06ff (patch)
tree15a1abee0594be92cc08c86edc544da132ba27d8
parent51326912d61b05a33dd9cf3ca9befa6e2715b346 (diff)
downloadPeerTube-5f189c9c85449951254646ddf6cd6c84bc4c06ff.tar.gz
PeerTube-5f189c9c85449951254646ddf6cd6c84bc4c06ff.tar.zst
PeerTube-5f189c9c85449951254646ddf6cd6c84bc4c06ff.zip
Add hooks documentation
-rw-r--r--server/tests/api/travis-1.sh2
-rw-r--r--server/tests/api/travis-2.sh2
-rw-r--r--server/tests/api/travis-3.sh2
-rw-r--r--server/tests/api/travis-4.sh2
-rw-r--r--server/tests/plugins/index.ts4
-rw-r--r--shared/models/plugins/client-hook.model.ts13
-rw-r--r--shared/models/plugins/server-hook.model.ts22
-rw-r--r--support/doc/plugins/guide.md2
8 files changed, 41 insertions, 8 deletions
diff --git a/server/tests/api/travis-1.sh b/server/tests/api/travis-1.sh
index 4572416b7..db4021b25 100644
--- a/server/tests/api/travis-1.sh
+++ b/server/tests/api/travis-1.sh
@@ -6,5 +6,5 @@ checkParamFiles=$(find server/tests/api/check-params -type f | grep -v index.ts
6notificationsFiles=$(find server/tests/api/notifications -type f | grep -v index.ts | xargs echo) 6notificationsFiles=$(find server/tests/api/notifications -type f | grep -v index.ts | xargs echo)
7searchFiles=$(find server/tests/api/search -type f | grep -v index.ts | xargs echo) 7searchFiles=$(find server/tests/api/search -type f | grep -v index.ts | xargs echo)
8 8
9MOCHA_PARALLEL=true mocha --timeout 5000 --retries 3 --exit --require ts-node/register --bail \ 9MOCHA_PARALLEL=true mocha --timeout 5000 --exit --require ts-node/register --bail \
10 $notificationsFiles $searchFiles $checkParamFiles 10 $notificationsFiles $searchFiles $checkParamFiles
diff --git a/server/tests/api/travis-2.sh b/server/tests/api/travis-2.sh
index 3c519ef68..ba7a061b0 100644
--- a/server/tests/api/travis-2.sh
+++ b/server/tests/api/travis-2.sh
@@ -5,5 +5,5 @@ set -eu
5serverFiles=$(find server/tests/api/server -type f | grep -v index.ts | xargs echo) 5serverFiles=$(find server/tests/api/server -type f | grep -v index.ts | xargs echo)
6usersFiles=$(find server/tests/api/users -type f | grep -v index.ts | xargs echo) 6usersFiles=$(find server/tests/api/users -type f | grep -v index.ts | xargs echo)
7 7
8MOCHA_PARALLEL=true mocha --timeout 5000 --retries 3 --exit --require ts-node/register --bail \ 8MOCHA_PARALLEL=true mocha --timeout 5000 --exit --require ts-node/register --bail \
9 $serverFiles $usersFiles 9 $serverFiles $usersFiles
diff --git a/server/tests/api/travis-3.sh b/server/tests/api/travis-3.sh
index 97dadafca..82457222c 100644
--- a/server/tests/api/travis-3.sh
+++ b/server/tests/api/travis-3.sh
@@ -4,5 +4,5 @@ set -eu
4 4
5videosFiles=$(find server/tests/api/videos -type f | grep -v index.ts | xargs echo) 5videosFiles=$(find server/tests/api/videos -type f | grep -v index.ts | xargs echo)
6 6
7MOCHA_PARALLEL=true mocha --timeout 5000 --retries 3 --exit --require ts-node/register --bail \ 7MOCHA_PARALLEL=true mocha --timeout 5000 --exit --require ts-node/register --bail \
8 $videosFiles 8 $videosFiles
diff --git a/server/tests/api/travis-4.sh b/server/tests/api/travis-4.sh
index 6009b1f0e..875986182 100644
--- a/server/tests/api/travis-4.sh
+++ b/server/tests/api/travis-4.sh
@@ -5,5 +5,5 @@ set -eu
5redundancyFiles=$(find server/tests/api/redundancy -type f | grep -v index.ts | xargs echo) 5redundancyFiles=$(find server/tests/api/redundancy -type f | grep -v index.ts | xargs echo)
6activitypubFiles=$(find server/tests/api/activitypub -type f | grep -v index.ts | xargs echo) 6activitypubFiles=$(find server/tests/api/activitypub -type f | grep -v index.ts | xargs echo)
7 7
8MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel $1 --timeout 5000 --retries 3 --exit --require ts-node/register --bail \ 8MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel $1 --timeout 5000 --exit --require ts-node/register --bail \
9 $redundancyFiles $activitypubFiles 9 $redundancyFiles $activitypubFiles
diff --git a/server/tests/plugins/index.ts b/server/tests/plugins/index.ts
index b640ecc9e..d97ca1515 100644
--- a/server/tests/plugins/index.ts
+++ b/server/tests/plugins/index.ts
@@ -1,2 +1,2 @@
1export * from './action-hooks' 1import './action-hooks'
2export * from './filter-hooks' 2import './filter-hooks'
diff --git a/shared/models/plugins/client-hook.model.ts b/shared/models/plugins/client-hook.model.ts
index bf444fe5a..87e8092c0 100644
--- a/shared/models/plugins/client-hook.model.ts
+++ b/shared/models/plugins/client-hook.model.ts
@@ -1,29 +1,38 @@
1// Data from API hooks: {hookType}:api.{location}.{elementType}.{actionType}.{target} 1// Data from API hooks: {hookType}:api.{location}.{elementType}.{actionType}.{target}
2 2
3export const clientFilterHookObject = { 3export const clientFilterHookObject = {
4 // Filter params/result of the function that fetch videos of the trending page
4 'filter:api.trending-videos.videos.list.params': true, 5 'filter:api.trending-videos.videos.list.params': true,
5 'filter:api.trending-videos.videos.list.result': true, 6 'filter:api.trending-videos.videos.list.result': true,
6 7
8 // Filter params/result of the function that fetch videos of the local page
7 'filter:api.local-videos.videos.list.params': true, 9 'filter:api.local-videos.videos.list.params': true,
8 'filter:api.local-videos.videos.list.result': true, 10 'filter:api.local-videos.videos.list.result': true,
9 11
12 // Filter params/result of the function that fetch videos of the recently-added page
10 'filter:api.recently-added-videos.videos.list.params': true, 13 'filter:api.recently-added-videos.videos.list.params': true,
11 'filter:api.recently-added-videos.videos.list.result': true, 14 'filter:api.recently-added-videos.videos.list.result': true,
12 15
16 // Filter params/result of the function that fetch videos of the user subscription page
13 'filter:api.user-subscriptions-videos.videos.list.params': true, 17 'filter:api.user-subscriptions-videos.videos.list.params': true,
14 'filter:api.user-subscriptions-videos.videos.list.result': true, 18 'filter:api.user-subscriptions-videos.videos.list.result': true,
15 19
20 // Filter params/result of the function that fetch the video of the video-watch page
16 'filter:api.video-watch.video.get.params': true, 21 'filter:api.video-watch.video.get.params': true,
17 'filter:api.video-watch.video.get.result': true, 22 'filter:api.video-watch.video.get.result': true,
18 23
24 // Filter params/result of the function that fetch the threads of the video-watch page
19 'filter:api.video-watch.video-threads.list.params': true, 25 'filter:api.video-watch.video-threads.list.params': true,
20 'filter:api.video-watch.video-threads.list.result': true, 26 'filter:api.video-watch.video-threads.list.result': true,
21 27
28 // Filter params/result of the function that fetch the replies of a thread in the video-watch page
22 'filter:api.video-watch.video-thread-replies.list.params': true, 29 'filter:api.video-watch.video-thread-replies.list.params': true,
23 'filter:api.video-watch.video-thread-replies.list.result': true, 30 'filter:api.video-watch.video-thread-replies.list.result': true,
24 31
32 // Filter params/result of the function that fetch videos according to the user search
25 'filter:api.search.videos.list.params': true, 33 'filter:api.search.videos.list.params': true,
26 'filter:api.search.videos.list.result': true, 34 'filter:api.search.videos.list.result': true,
35 // Filter params/result of the function that fetch video-channels according to the user search
27 'filter:api.search.video-channels.list.params': true, 36 'filter:api.search.video-channels.list.params': true,
28 'filter:api.search.video-channels.list.result': true 37 'filter:api.search.video-channels.list.result': true
29} 38}
@@ -31,11 +40,15 @@ export const clientFilterHookObject = {
31export type ClientFilterHookName = keyof typeof clientFilterHookObject 40export type ClientFilterHookName = keyof typeof clientFilterHookObject
32 41
33export const clientActionHookObject = { 42export const clientActionHookObject = {
43 // Fired when the application is being initialized
34 'action:application.init': true, 44 'action:application.init': true,
35 45
46 // Fired when the video watch page is being initialized
36 'action:video-watch.init': true, 47 'action:video-watch.init': true,
48 // Fired when the video watch page loaded the video
37 'action:video-watch.video.loaded': true, 49 'action:video-watch.video.loaded': true,
38 50
51 // Fired when the search page is being initialized
39 'action:search.init': true 52 'action:search.init': true
40} 53}
41 54
diff --git a/shared/models/plugins/server-hook.model.ts b/shared/models/plugins/server-hook.model.ts
index fc4c51160..32c7f4688 100644
--- a/shared/models/plugins/server-hook.model.ts
+++ b/shared/models/plugins/server-hook.model.ts
@@ -1,35 +1,57 @@
1// {hookType}:{api?}.{location}.{subLocation?}.{actionType}.{target} 1// {hookType}:{api?}.{location}.{subLocation?}.{actionType}.{target}
2 2
3export const serverFilterHookObject = { 3export 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)
4 'filter:api.videos.list.params': true, 6 'filter:api.videos.list.params': true,
5 'filter:api.videos.list.result': 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)
6 'filter:api.video.get.result': true, 10 'filter:api.video.get.result': true,
7 11
12 // Filter the result of the accept upload function
13 // If this function returns false then the upload is aborted with an error
8 'filter:api.video.upload.accept.result': true, 14 'filter:api.video.upload.accept.result': true,
15 // Filter the result of the accept comment (thread or reply) functions
16 // If the functions return false then the user cannot post its comment
9 'filter:api.video-thread.create.accept.result': true, 17 'filter:api.video-thread.create.accept.result': true,
10 'filter:api.video-comment-reply.create.accept.result': true, 18 'filter:api.video-comment-reply.create.accept.result': true,
11 19
20 // Filter params/result used to list threads of a specific video
21 // (used by the video watch page)
12 'filter:api.video-threads.list.params': true, 22 'filter:api.video-threads.list.params': true,
13 'filter:api.video-threads.list.result': true, 23 'filter:api.video-threads.list.result': true,
14 24
25 // Filter params/result used to list replies of a specific thread
26 // (used by the video watch page when we click on the "View replies" button)
15 'filter:api.video-thread-comments.list.params': true, 27 'filter:api.video-thread-comments.list.params': true,
16 'filter:api.video-thread-comments.list.result': true, 28 'filter:api.video-thread-comments.list.result': true,
17 29
30 // Filter result used to check if we need to auto blacklist a video
31 // (fired when a local or remote video is created or updated)
18 'filter:video.auto-blacklist.result': true 32 'filter:video.auto-blacklist.result': true
19} 33}
20 34
21export type ServerFilterHookName = keyof typeof serverFilterHookObject 35export type ServerFilterHookName = keyof typeof serverFilterHookObject
22 36
23export const serverActionHookObject = { 37export const serverActionHookObject = {
38 // Fired when the application has been loaded and is listening HTTP requests
24 'action:application.listening': true, 39 'action:application.listening': true,
25 40
41 // Fired when a local video is updated
26 'action:api.video.updated': true, 42 'action:api.video.updated': true,
43 // Fired when a local video is deleted
27 'action:api.video.deleted': true, 44 'action:api.video.deleted': true,
45 // Fired when a local video is uploaded
28 'action:api.video.uploaded': true, 46 'action:api.video.uploaded': true,
47 // Fired when a local video is viewed
29 'action:api.video.viewed': true, 48 'action:api.video.viewed': true,
30 49
50 // Fired when a thread is created
31 'action:api.video-thread.created': true, 51 'action:api.video-thread.created': true,
52 // Fired when a reply to a thread is created
32 'action:api.video-comment-reply.created': true, 53 'action:api.video-comment-reply.created': true,
54 // Fired when a comment (thread or reply) is deleted
33 'action:api.video-comment.deleted': true 55 'action:api.video-comment.deleted': true
34} 56}
35 57
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md
index 252cbc2e2..0b2d337eb 100644
--- a/support/doc/plugins/guide.md
+++ b/support/doc/plugins/guide.md
@@ -297,5 +297,3 @@ If you want to create an antispam/moderation plugin, you could use the following
297 * `filter:api.video-thread-comments.list.result`: to change/hide the text of replies 297 * `filter:api.video-thread-comments.list.result`: to change/hide the text of replies
298 * `filter:video.auto-blacklist.result`: to automatically blacklist local or remote videos 298 * `filter:video.auto-blacklist.result`: to automatically blacklist local or remote videos
299 299
300
301