aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-06 17:39:07 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-07 08:33:34 +0200
commitfeb34f6b6b991046aab6a10df747b48fa4da07a7 (patch)
tree02bb7277d45be166ba48caef2ee73bf89dbe1258 /server/middlewares/validators
parentd170c5c580abf6f90d7bf144e2417e248ce2ecf4 (diff)
downloadPeerTube-feb34f6b6b991046aab6a10df747b48fa4da07a7.tar.gz
PeerTube-feb34f6b6b991046aab6a10df747b48fa4da07a7.tar.zst
PeerTube-feb34f6b6b991046aab6a10df747b48fa4da07a7.zip
Use video abuse filters on client side
Diffstat (limited to 'server/middlewares/validators')
-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