aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/controllers/api/overviews.ts8
-rw-r--r--server/tests/fixtures/peertube-plugin-test/main.js9
-rw-r--r--server/tests/plugins/filter-hooks.ts8
3 files changed, 18 insertions, 7 deletions
diff --git a/server/controllers/api/overviews.ts b/server/controllers/api/overviews.ts
index 727ed66d7..2dfac15ef 100644
--- a/server/controllers/api/overviews.ts
+++ b/server/controllers/api/overviews.ts
@@ -109,7 +109,7 @@ async function getVideos (
109 res: express.Response, 109 res: express.Response,
110 where: { videoChannelId?: number, tagsOneOf?: string[], categoryOneOf?: number[] } 110 where: { videoChannelId?: number, tagsOneOf?: string[], categoryOneOf?: number[] }
111) { 111) {
112 let query = Object.assign({ 112 const query = await Hooks.wrapObject({
113 start: 0, 113 start: 0,
114 count: 12, 114 count: 12,
115 sort: '-createdAt', 115 sort: '-createdAt',
@@ -117,10 +117,10 @@ async function getVideos (
117 nsfw: buildNSFWFilter(res), 117 nsfw: buildNSFWFilter(res),
118 user: res.locals.oauth ? res.locals.oauth.token.User : undefined, 118 user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
119 withFiles: false, 119 withFiles: false,
120 countVideos: false 120 countVideos: false,
121 }, where)
122 121
123 query = await Hooks.wrapObject(query, 'filter:api.overviews.videos.list.params') 122 ...where
123 }, 'filter:api.overviews.videos.list.params')
124 124
125 const { data } = await Hooks.wrapPromiseFun( 125 const { data } = await Hooks.wrapPromiseFun(
126 VideoModel.listForApi, 126 VideoModel.listForApi,
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js
index f8e6f0b98..db405ff31 100644
--- a/server/tests/fixtures/peertube-plugin-test/main.js
+++ b/server/tests/fixtures/peertube-plugin-test/main.js
@@ -234,7 +234,7 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
234 }) 234 })
235 235
236 { 236 {
237 const searchHooks = [ 237 const filterHooks = [
238 'filter:api.search.videos.local.list.params', 238 'filter:api.search.videos.local.list.params',
239 'filter:api.search.videos.local.list.result', 239 'filter:api.search.videos.local.list.result',
240 'filter:api.search.videos.index.list.params', 240 'filter:api.search.videos.index.list.params',
@@ -246,10 +246,13 @@ async function register ({ registerHook, registerSetting, settingsManager, stora
246 'filter:api.search.video-playlists.local.list.params', 246 'filter:api.search.video-playlists.local.list.params',
247 'filter:api.search.video-playlists.local.list.result', 247 'filter:api.search.video-playlists.local.list.result',
248 'filter:api.search.video-playlists.index.list.params', 248 'filter:api.search.video-playlists.index.list.params',
249 'filter:api.search.video-playlists.index.list.result' 249 'filter:api.search.video-playlists.index.list.result',
250
251 'filter:api.overviews.videos.list.params',
252 'filter:api.overviews.videos.list.result'
250 ] 253 ]
251 254
252 for (const h of searchHooks) { 255 for (const h of filterHooks) {
253 registerHook({ 256 registerHook({
254 target: h, 257 target: h,
255 handler: (obj) => { 258 handler: (obj) => {
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index c00ac8f91..02915f08c 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -255,6 +255,14 @@ describe('Test plugin filter hooks', function () {
255 expect(thread.comment.text.endsWith(' <3')).to.be.true 255 expect(thread.comment.text.endsWith(' <3')).to.be.true
256 }) 256 })
257 257
258 it('Should run filter:api.overviews.videos.list.{params,result}', async function () {
259 await servers[0].overviews.getVideos({ page: 1 })
260
261 // 3 because we get 3 samples per page
262 await servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.params', 3)
263 await servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.result', 3)
264 })
265
258 describe('Should run filter:video.auto-blacklist.result', function () { 266 describe('Should run filter:video.auto-blacklist.result', function () {
259 267
260 async function checkIsBlacklisted (id: number | string, value: boolean) { 268 async function checkIsBlacklisted (id: number | string, value: boolean) {