aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-16 13:49:09 +0100
committerChocobozzz <me@florianbigard.com>2020-11-16 13:57:14 +0100
commit19149d45b8f68569535f7188ef25e09e3d62c8b4 (patch)
tree92da0e0db2b0e277b2110a630f502433c86c9119 /server/middlewares/validators/videos
parent8872828d59a5152e27734711ae30ebe86e84f570 (diff)
parentf1273314593a4a7dc7ec9594ce0c6c3ae8f62b34 (diff)
downloadPeerTube-19149d45b8f68569535f7188ef25e09e3d62c8b4.tar.gz
PeerTube-19149d45b8f68569535f7188ef25e09e3d62c8b4.tar.zst
PeerTube-19149d45b8f68569535f7188ef25e09e3d62c8b4.zip
Merge branch 'feature/admin-comments' into develop
Diffstat (limited to 'server/middlewares/validators/videos')
-rw-r--r--server/middlewares/validators/videos/video-comments.ts33
1 files changed, 31 insertions, 2 deletions
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts
index 77f5c6ff3..a3c9febc4 100644
--- a/server/middlewares/validators/videos/video-comments.ts
+++ b/server/middlewares/validators/videos/video-comments.ts
@@ -1,8 +1,8 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { MUserAccountUrl } from '@server/types/models' 3import { MUserAccountUrl } from '@server/types/models'
4import { UserRight } from '../../../../shared' 4import { UserRight } from '../../../../shared'
5import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc' 5import { exists, isBooleanValid, isIdOrUUIDValid, isIdValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc'
6import { 6import {
7 doesVideoCommentExist, 7 doesVideoCommentExist,
8 doesVideoCommentThreadExist, 8 doesVideoCommentThreadExist,
@@ -15,6 +15,34 @@ import { Hooks } from '../../../lib/plugins/hooks'
15import { MCommentOwnerVideoReply, MVideo, MVideoFullLight } from '../../../types/models/video' 15import { MCommentOwnerVideoReply, MVideo, MVideoFullLight } from '../../../types/models/video'
16import { areValidationErrors } from '../utils' 16import { areValidationErrors } from '../utils'
17 17
18const listVideoCommentsValidator = [
19 query('isLocal')
20 .optional()
21 .customSanitizer(toBooleanOrNull)
22 .custom(isBooleanValid)
23 .withMessage('Should have a valid is local boolean'),
24
25 query('search')
26 .optional()
27 .custom(exists).withMessage('Should have a valid search'),
28
29 query('searchAccount')
30 .optional()
31 .custom(exists).withMessage('Should have a valid account search'),
32
33 query('searchVideo')
34 .optional()
35 .custom(exists).withMessage('Should have a valid video search'),
36
37 (req: express.Request, res: express.Response, next: express.NextFunction) => {
38 logger.debug('Checking listVideoCommentsValidator parameters.', { parameters: req.query })
39
40 if (areValidationErrors(req, res)) return
41
42 return next()
43 }
44]
45
18const listVideoCommentThreadsValidator = [ 46const listVideoCommentThreadsValidator = [
19 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), 47 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
20 48
@@ -116,6 +144,7 @@ export {
116 listVideoCommentThreadsValidator, 144 listVideoCommentThreadsValidator,
117 listVideoThreadCommentsValidator, 145 listVideoThreadCommentsValidator,
118 addVideoCommentThreadValidator, 146 addVideoCommentThreadValidator,
147 listVideoCommentsValidator,
119 addVideoCommentReplyValidator, 148 addVideoCommentReplyValidator,
120 videoCommentGetValidator, 149 videoCommentGetValidator,
121 removeVideoCommentValidator 150 removeVideoCommentValidator