aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/fixtures
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-05-14 11:10:26 +0200
committerGitHub <noreply@github.com>2020-05-14 11:10:26 +0200
commit2158ac90341dc3fcae958540de65032da25c8d6e (patch)
treea780923d701f3daa130996768e38c1e1b6a0646c /server/tests/fixtures
parent7405b6ba897dbce1b4fd50c92174f1df5ac15adc (diff)
downloadPeerTube-2158ac90341dc3fcae958540de65032da25c8d6e.tar.gz
PeerTube-2158ac90341dc3fcae958540de65032da25c8d6e.tar.zst
PeerTube-2158ac90341dc3fcae958540de65032da25c8d6e.zip
Add server plugin filter hooks for import with torrent and url (#2621)
* Add server plugin filter hooks for import with torrent and url * WIP: pre and post-import filter hooks * Rebased * Cleanup filters to accept imports Co-authored-by: Chocobozzz <me@florianbigard.com>
Diffstat (limited to 'server/tests/fixtures')
-rw-r--r--server/tests/fixtures/peertube-plugin-test/main.js42
1 files changed, 41 insertions, 1 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js
index 69796ab07..a45e98fb5 100644
--- a/server/tests/fixtures/peertube-plugin-test/main.js
+++ b/server/tests/fixtures/peertube-plugin-test/main.js
@@ -50,7 +50,47 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
50 target: 'filter:api.video.upload.accept.result', 50 target: 'filter:api.video.upload.accept.result',
51 handler: ({ accepted }, { videoBody }) => { 51 handler: ({ accepted }, { videoBody }) => {
52 if (!accepted) return { accepted: false } 52 if (!accepted) return { accepted: false }
53 if (videoBody.name.indexOf('bad word') !== -1) return { accepted: false, errorMessage: 'bad word '} 53 if (videoBody.name.indexOf('bad word') !== -1) return { accepted: false, errorMessage: 'bad word' }
54
55 return { accepted: true }
56 }
57 })
58
59 registerHook({
60 target: 'filter:api.video.pre-import-url.accept.result',
61 handler: ({ accepted }, { videoImportBody }) => {
62 if (!accepted) return { accepted: false }
63 if (videoImportBody.targetUrl.includes('bad')) return { accepted: false, errorMessage: 'bad target url' }
64
65 return { accepted: true }
66 }
67 })
68
69 registerHook({
70 target: 'filter:api.video.pre-import-torrent.accept.result',
71 handler: ({ accepted }, { videoImportBody }) => {
72 if (!accepted) return { accepted: false }
73 if (videoImportBody.name.includes('bad torrent')) return { accepted: false, errorMessage: 'bad torrent' }
74
75 return { accepted: true }
76 }
77 })
78
79 registerHook({
80 target: 'filter:api.video.post-import-url.accept.result',
81 handler: ({ accepted }, { video }) => {
82 if (!accepted) return { accepted: false }
83 if (video.name.includes('bad word')) return { accepted: false, errorMessage: 'bad word' }
84
85 return { accepted: true }
86 }
87 })
88
89 registerHook({
90 target: 'filter:api.video.post-import-torrent.accept.result',
91 handler: ({ accepted }, { video }) => {
92 if (!accepted) return { accepted: false }
93 if (video.name.includes('bad word')) return { accepted: false, errorMessage: 'bad word' }
54 94
55 return { accepted: true } 95 return { accepted: true }
56 } 96 }