From d324756edb836672f12284cd18e642a658b273d8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 3 Nov 2021 11:32:41 +0100 Subject: Add ability to filter by file type --- server/middlewares/validators/videos/videos.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'server/middlewares/validators') diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 44233b653..5f1234379 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts @@ -496,6 +496,14 @@ const commonVideosFiltersValidator = [ .optional() .customSanitizer(toBooleanOrNull) .custom(isBooleanValid).withMessage('Should have a valid local boolean'), + query('hasHLSFiles') + .optional() + .customSanitizer(toBooleanOrNull) + .custom(isBooleanValid).withMessage('Should have a valid has hls boolean'), + query('hasWebtorrentFiles') + .optional() + .customSanitizer(toBooleanOrNull) + .custom(isBooleanValid).withMessage('Should have a valid has webtorrent boolean'), query('skipCount') .optional() .customSanitizer(toBooleanOrNull) @@ -525,12 +533,13 @@ const commonVideosFiltersValidator = [ const user = res.locals.oauth?.token.User - if (req.query.include && (!user || user.hasRight(UserRight.SEE_ALL_VIDEOS) !== true)) { - res.fail({ - status: HttpStatusCode.UNAUTHORIZED_401, - message: 'You are not allowed to see all local videos.' - }) - return + if ((!user || user.hasRight(UserRight.SEE_ALL_VIDEOS) !== true)) { + if (req.query.include) { + return res.fail({ + status: HttpStatusCode.UNAUTHORIZED_401, + message: 'You are not allowed to see all videos.' + }) + } } return next() -- cgit v1.2.3