From a0606360a70fc0134475ee9e77a568b299dad2c8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 28 Nov 2023 07:01:12 +0100 Subject: [PATCH] Return 400 if filter query is still there --- .../tests/src/api/check-params/videos-common-filters.ts | 8 +++++++- server/core/middlewares/validators/videos/videos.ts | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/tests/src/api/check-params/videos-common-filters.ts b/packages/tests/src/api/check-params/videos-common-filters.ts index dbae3010c..3fb725ebc 100644 --- a/packages/tests/src/api/check-params/videos-common-filters.ts +++ b/packages/tests/src/api/check-params/videos-common-filters.ts @@ -59,6 +59,7 @@ describe('Test video filters validators', function () { expectedStatus: HttpStatusCodeType excludeAlreadyWatched?: boolean unauthenticatedUser?: boolean + filter?: string }) { const paths = [ '/api/v1/video-channels/root_channel/videos', @@ -80,13 +81,18 @@ describe('Test video filters validators', function () { isLocal: options.isLocal, privacyOneOf: options.privacyOneOf, include: options.include, - excludeAlreadyWatched: options.excludeAlreadyWatched + excludeAlreadyWatched: options.excludeAlreadyWatched, + filter: options.filter }, expectedStatus: options.expectedStatus }) } } + it('Should fail with the old filter query param', async function () { + await testEndpoints({ filter: 'all-local', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) + }) + it('Should fail with a bad privacyOneOf', async function () { await testEndpoints({ privacyOneOf: [ 'toto' ] as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) diff --git a/server/core/middlewares/validators/videos/videos.ts b/server/core/middlewares/validators/videos/videos.ts index a1f6e72c8..1ee5d8c4d 100644 --- a/server/core/middlewares/validators/videos/videos.ts +++ b/server/core/middlewares/validators/videos/videos.ts @@ -515,6 +515,15 @@ const commonVideosFiltersValidator = [ }) return false } + + if (req.query.filter) { + res.fail({ + status: HttpStatusCode.BAD_REQUEST_400, + message: '"filter" query parameter is not supported anymore by PeerTube. Please use "isLocal" and "include" instead' + }) + return false + } + return next() } ]