aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/fixtures
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-06 13:59:50 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commit3cabf3532b9118a19311f14ca3e171d12d554a2f (patch)
tree46072616df4623d91c87f648e4033b3f1d05d404 /server/tests/fixtures
parentc8f3cfeba7acc2ab9c5f03161d22856202a49326 (diff)
downloadPeerTube-3cabf3532b9118a19311f14ca3e171d12d554a2f.tar.gz
PeerTube-3cabf3532b9118a19311f14ca3e171d12d554a2f.tar.zst
PeerTube-3cabf3532b9118a19311f14ca3e171d12d554a2f.zip
Add live server hooks
Diffstat (limited to 'server/tests/fixtures')
-rw-r--r--server/tests/fixtures/peertube-plugin-test/main.js25
1 files changed, 17 insertions, 8 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js
index a45e98fb5..322c0610c 100644
--- a/server/tests/fixtures/peertube-plugin-test/main.js
+++ b/server/tests/fixtures/peertube-plugin-test/main.js
@@ -7,6 +7,8 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
7 'action:api.video.uploaded', 7 'action:api.video.uploaded',
8 'action:api.video.viewed', 8 'action:api.video.viewed',
9 9
10 'action:api.live-video.created',
11
10 'action:api.video-thread.created', 12 'action:api.video-thread.created',
11 'action:api.video-comment-reply.created', 13 'action:api.video-comment-reply.created',
12 'action:api.video-comment.deleted', 14 'action:api.video-comment.deleted',
@@ -46,15 +48,22 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
46 } 48 }
47 }) 49 })
48 50
49 registerHook({ 51 for (const hook of [ 'filter:api.video.upload.accept.result', 'filter:api.live-video.create.accept.result' ]) {
50 target: 'filter:api.video.upload.accept.result', 52 registerHook({
51 handler: ({ accepted }, { videoBody }) => { 53 target: hook,
52 if (!accepted) return { accepted: false } 54 handler: ({ accepted }, { videoBody, liveVideoBody }) => {
53 if (videoBody.name.indexOf('bad word') !== -1) return { accepted: false, errorMessage: 'bad word' } 55 if (!accepted) return { accepted: false }
54 56
55 return { accepted: true } 57 const name = videoBody
56 } 58 ? videoBody.name
57 }) 59 : liveVideoBody.name
60
61 if (name.indexOf('bad word') !== -1) return { accepted: false, errorMessage: 'bad word' }
62
63 return { accepted: true }
64 }
65 })
66 }
58 67
59 registerHook({ 68 registerHook({
60 target: 'filter:api.video.pre-import-url.accept.result', 69 target: 'filter:api.video.pre-import-url.accept.result',