diff options
Diffstat (limited to 'server/middlewares/validators/video-blacklist.ts')
-rw-r--r-- | server/middlewares/validators/video-blacklist.ts | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/server/middlewares/validators/video-blacklist.ts b/server/middlewares/validators/video-blacklist.ts deleted file mode 100644 index 95a2b9f17..000000000 --- a/server/middlewares/validators/video-blacklist.ts +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | import * as express from 'express' | ||
2 | import { body, param } from 'express-validator/check' | ||
3 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' | ||
4 | import { isVideoExist } from '../../helpers/custom-validators/videos' | ||
5 | import { logger } from '../../helpers/logger' | ||
6 | import { areValidationErrors } from './utils' | ||
7 | import { isVideoBlacklistExist, isVideoBlacklistReasonValid } from '../../helpers/custom-validators/video-blacklist' | ||
8 | |||
9 | const videosBlacklistRemoveValidator = [ | ||
10 | param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), | ||
11 | |||
12 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
13 | logger.debug('Checking blacklistRemove parameters.', { parameters: req.params }) | ||
14 | |||
15 | if (areValidationErrors(req, res)) return | ||
16 | if (!await isVideoExist(req.params.videoId, res)) return | ||
17 | if (!await isVideoBlacklistExist(res.locals.video.id, res)) return | ||
18 | |||
19 | return next() | ||
20 | } | ||
21 | ] | ||
22 | |||
23 | const videosBlacklistAddValidator = [ | ||
24 | param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), | ||
25 | body('reason') | ||
26 | .optional() | ||
27 | .custom(isVideoBlacklistReasonValid).withMessage('Should have a valid reason'), | ||
28 | |||
29 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
30 | logger.debug('Checking videosBlacklistAdd parameters', { parameters: req.params }) | ||
31 | |||
32 | if (areValidationErrors(req, res)) return | ||
33 | if (!await isVideoExist(req.params.videoId, res)) return | ||
34 | |||
35 | return next() | ||
36 | } | ||
37 | ] | ||
38 | |||
39 | const videosBlacklistUpdateValidator = [ | ||
40 | param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), | ||
41 | body('reason') | ||
42 | .optional() | ||
43 | .custom(isVideoBlacklistReasonValid).withMessage('Should have a valid reason'), | ||
44 | |||
45 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
46 | logger.debug('Checking videosBlacklistUpdate parameters', { parameters: req.params }) | ||
47 | |||
48 | if (areValidationErrors(req, res)) return | ||
49 | if (!await isVideoExist(req.params.videoId, res)) return | ||
50 | if (!await isVideoBlacklistExist(res.locals.video.id, res)) return | ||
51 | |||
52 | return next() | ||
53 | } | ||
54 | ] | ||
55 | |||
56 | // --------------------------------------------------------------------------- | ||
57 | |||
58 | export { | ||
59 | videosBlacklistAddValidator, | ||
60 | videosBlacklistRemoveValidator, | ||
61 | videosBlacklistUpdateValidator | ||
62 | } | ||