diff options
author | Chocobozzz <me@florianbigard.com> | 2020-12-08 10:30:33 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-12-08 10:33:23 +0100 |
commit | 38267c0c8aa80f974a2c0b4c2bd33c8d8008ac94 (patch) | |
tree | dd99242abdd5a02de272be0f06ecfe03edadc575 /server/tests/fixtures/peertube-plugin-test/main.js | |
parent | 1bfc07e4cca1464c87c317060eb86742344467a6 (diff) | |
download | PeerTube-38267c0c8aa80f974a2c0b4c2bd33c8d8008ac94.tar.gz PeerTube-38267c0c8aa80f974a2c0b4c2bd33c8d8008ac94.tar.zst PeerTube-38267c0c8aa80f974a2c0b4c2bd33c8d8008ac94.zip |
Use dedicated hooks for account/channel videos
Diffstat (limited to 'server/tests/fixtures/peertube-plugin-test/main.js')
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test/main.js | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js index 322c0610c..e5a9f8df5 100644 --- a/server/tests/fixtures/peertube-plugin-test/main.js +++ b/server/tests/fixtures/peertube-plugin-test/main.js | |||
@@ -40,6 +40,26 @@ async function register ({ registerHook, registerSetting, settingsManager, stora | |||
40 | }) | 40 | }) |
41 | 41 | ||
42 | registerHook({ | 42 | registerHook({ |
43 | target: 'filter:api.accounts.videos.list.params', | ||
44 | handler: obj => addToCount(obj) | ||
45 | }) | ||
46 | |||
47 | registerHook({ | ||
48 | target: 'filter:api.accounts.videos.list.result', | ||
49 | handler: obj => addToTotal(obj, 2) | ||
50 | }) | ||
51 | |||
52 | registerHook({ | ||
53 | target: 'filter:api.video-channels.videos.list.params', | ||
54 | handler: obj => addToCount(obj, 3) | ||
55 | }) | ||
56 | |||
57 | registerHook({ | ||
58 | target: 'filter:api.video-channels.videos.list.result', | ||
59 | handler: obj => addToTotal(obj, 3) | ||
60 | }) | ||
61 | |||
62 | registerHook({ | ||
43 | target: 'filter:api.video.get.result', | 63 | target: 'filter:api.video.get.result', |
44 | handler: video => { | 64 | handler: video => { |
45 | video.name += ' <3' | 65 | video.name += ' <3' |
@@ -167,14 +187,14 @@ module.exports = { | |||
167 | 187 | ||
168 | // ############################################################################ | 188 | // ############################################################################ |
169 | 189 | ||
170 | function addToCount (obj) { | 190 | function addToCount (obj, amount = 1) { |
171 | return Object.assign({}, obj, { count: obj.count + 1 }) | 191 | return Object.assign({}, obj, { count: obj.count + amount }) |
172 | } | 192 | } |
173 | 193 | ||
174 | function addToTotal (result) { | 194 | function addToTotal (result, amount = 1) { |
175 | return { | 195 | return { |
176 | data: result.data, | 196 | data: result.data, |
177 | total: result.total + 1 | 197 | total: result.total + amount |
178 | } | 198 | } |
179 | } | 199 | } |
180 | 200 | ||