diff options
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/videos/video-blacklist.ts | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/server/middlewares/validators/videos/video-blacklist.ts b/server/middlewares/validators/videos/video-blacklist.ts index db318dcdb..1d7ddb2e3 100644 --- a/server/middlewares/validators/videos/video-blacklist.ts +++ b/server/middlewares/validators/videos/video-blacklist.ts | |||
@@ -1,10 +1,14 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param } from 'express-validator/check' | 2 | import { body, param, query } from 'express-validator/check' |
3 | import { isBooleanValid, isIdOrUUIDValid } from '../../../helpers/custom-validators/misc' | 3 | import { isBooleanValid, isIdOrUUIDValid } from '../../../helpers/custom-validators/misc' |
4 | import { doesVideoExist } from '../../../helpers/custom-validators/videos' | 4 | import { doesVideoExist } from '../../../helpers/custom-validators/videos' |
5 | import { logger } from '../../../helpers/logger' | 5 | import { logger } from '../../../helpers/logger' |
6 | import { areValidationErrors } from '../utils' | 6 | import { areValidationErrors } from '../utils' |
7 | import { doesVideoBlacklistExist, isVideoBlacklistReasonValid } from '../../../helpers/custom-validators/video-blacklist' | 7 | import { |
8 | doesVideoBlacklistExist, | ||
9 | isVideoBlacklistReasonValid, | ||
10 | isVideoBlacklistTypeValid | ||
11 | } from '../../../helpers/custom-validators/video-blacklist' | ||
8 | 12 | ||
9 | const videosBlacklistRemoveValidator = [ | 13 | const videosBlacklistRemoveValidator = [ |
10 | param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), | 14 | param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), |
@@ -65,10 +69,25 @@ const videosBlacklistUpdateValidator = [ | |||
65 | } | 69 | } |
66 | ] | 70 | ] |
67 | 71 | ||
72 | const videosBlacklistFiltersValidator = [ | ||
73 | query('type') | ||
74 | .optional() | ||
75 | .custom(isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'), | ||
76 | |||
77 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
78 | logger.debug('Checking videos blacklist filters query', { parameters: req.query }) | ||
79 | |||
80 | if (areValidationErrors(req, res)) return | ||
81 | |||
82 | return next() | ||
83 | } | ||
84 | ] | ||
85 | |||
68 | // --------------------------------------------------------------------------- | 86 | // --------------------------------------------------------------------------- |
69 | 87 | ||
70 | export { | 88 | export { |
71 | videosBlacklistAddValidator, | 89 | videosBlacklistAddValidator, |
72 | videosBlacklistRemoveValidator, | 90 | videosBlacklistRemoveValidator, |
73 | videosBlacklistUpdateValidator | 91 | videosBlacklistUpdateValidator, |
92 | videosBlacklistFiltersValidator | ||
74 | } | 93 | } |