aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-03 11:32:41 +0100
committerChocobozzz <me@florianbigard.com>2021-11-03 11:32:41 +0100
commitd324756edb836672f12284cd18e642a658b273d8 (patch)
tree3b323682bd7380491ad904daaeaea10be606e0f9 /server/middlewares/validators/videos
parentd5d9c5b79edf613e97a752a3d59062fb42045275 (diff)
downloadPeerTube-d324756edb836672f12284cd18e642a658b273d8.tar.gz
PeerTube-d324756edb836672f12284cd18e642a658b273d8.tar.zst
PeerTube-d324756edb836672f12284cd18e642a658b273d8.zip
Add ability to filter by file type
Diffstat (limited to 'server/middlewares/validators/videos')
-rw-r--r--server/middlewares/validators/videos/videos.ts21
1 files changed, 15 insertions, 6 deletions
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 = [
496 .optional() 496 .optional()
497 .customSanitizer(toBooleanOrNull) 497 .customSanitizer(toBooleanOrNull)
498 .custom(isBooleanValid).withMessage('Should have a valid local boolean'), 498 .custom(isBooleanValid).withMessage('Should have a valid local boolean'),
499 query('hasHLSFiles')
500 .optional()
501 .customSanitizer(toBooleanOrNull)
502 .custom(isBooleanValid).withMessage('Should have a valid has hls boolean'),
503 query('hasWebtorrentFiles')
504 .optional()
505 .customSanitizer(toBooleanOrNull)
506 .custom(isBooleanValid).withMessage('Should have a valid has webtorrent boolean'),
499 query('skipCount') 507 query('skipCount')
500 .optional() 508 .optional()
501 .customSanitizer(toBooleanOrNull) 509 .customSanitizer(toBooleanOrNull)
@@ -525,12 +533,13 @@ const commonVideosFiltersValidator = [
525 533
526 const user = res.locals.oauth?.token.User 534 const user = res.locals.oauth?.token.User
527 535
528 if (req.query.include && (!user || user.hasRight(UserRight.SEE_ALL_VIDEOS) !== true)) { 536 if ((!user || user.hasRight(UserRight.SEE_ALL_VIDEOS) !== true)) {
529 res.fail({ 537 if (req.query.include) {
530 status: HttpStatusCode.UNAUTHORIZED_401, 538 return res.fail({
531 message: 'You are not allowed to see all local videos.' 539 status: HttpStatusCode.UNAUTHORIZED_401,
532 }) 540 message: 'You are not allowed to see all videos.'
533 return 541 })
542 }
534 } 543 }
535 544
536 return next() 545 return next()