aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/videos/video-abuses.ts45
1 files changed, 41 insertions, 4 deletions
diff --git a/server/middlewares/validators/videos/video-abuses.ts b/server/middlewares/validators/videos/video-abuses.ts
index 7c316fe13..901997bcb 100644
--- a/server/middlewares/validators/videos/video-abuses.ts
+++ b/server/middlewares/validators/videos/video-abuses.ts
@@ -1,14 +1,15 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc' 3import { exists, isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
4import { logger } from '../../../helpers/logger'
5import { areValidationErrors } from '../utils'
6import { 4import {
5 isAbuseVideoIsValid,
7 isVideoAbuseModerationCommentValid, 6 isVideoAbuseModerationCommentValid,
8 isVideoAbuseReasonValid, 7 isVideoAbuseReasonValid,
9 isVideoAbuseStateValid 8 isVideoAbuseStateValid
10} from '../../../helpers/custom-validators/video-abuses' 9} from '../../../helpers/custom-validators/video-abuses'
10import { logger } from '../../../helpers/logger'
11import { doesVideoAbuseExist, doesVideoExist } from '../../../helpers/middlewares' 11import { doesVideoAbuseExist, doesVideoExist } from '../../../helpers/middlewares'
12import { areValidationErrors } from '../utils'
12 13
13const videoAbuseReportValidator = [ 14const videoAbuseReportValidator = [
14 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), 15 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
@@ -58,9 +59,45 @@ const videoAbuseUpdateValidator = [
58 } 59 }
59] 60]
60 61
62const videoAbuseListValidator = [
63 query('id')
64 .optional()
65 .custom(isIdValid).withMessage('Should have a valid id'),
66 query('search')
67 .optional()
68 .custom(exists).withMessage('Should have a valid search'),
69 query('state')
70 .optional()
71 .custom(isVideoAbuseStateValid).withMessage('Should have a valid video abuse state'),
72 query('videoIs')
73 .optional()
74 .custom(isAbuseVideoIsValid).withMessage('Should have a valid "video is" attribute'),
75 query('searchReporter')
76 .optional()
77 .custom(exists).withMessage('Should have a valid reporter search'),
78 query('searchReportee')
79 .optional()
80 .custom(exists).withMessage('Should have a valid reportee search'),
81 query('searchVideo')
82 .optional()
83 .custom(exists).withMessage('Should have a valid video search'),
84 query('searchVideoChannel')
85 .optional()
86 .custom(exists).withMessage('Should have a valid video channel search'),
87
88 (req: express.Request, res: express.Response, next: express.NextFunction) => {
89 logger.debug('Checking videoAbuseListValidator parameters', { parameters: req.body })
90
91 if (areValidationErrors(req, res)) return
92
93 return next()
94 }
95]
96
61// --------------------------------------------------------------------------- 97// ---------------------------------------------------------------------------
62 98
63export { 99export {
100 videoAbuseListValidator,
64 videoAbuseReportValidator, 101 videoAbuseReportValidator,
65 videoAbuseGetValidator, 102 videoAbuseGetValidator,
66 videoAbuseUpdateValidator 103 videoAbuseUpdateValidator