Return 400 if filter query is still there

pull/6064/head
Chocobozzz 2023-11-28 07:01:12 +01:00
parent d3849e9b22
commit a0606360a7
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 16 additions and 1 deletions

View File

@ -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 })
})

View File

@ -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()
}
]