aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-13 16:38:23 +0100
committerChocobozzz <me@florianbigard.com>2020-11-13 16:38:23 +0100
commit0f8d00e3144060270d7fe603865fccaf18649c47 (patch)
tree6ccd0b44735ea4541a53d4fda17459260a69e676 /server/middlewares/validators
parentdc13623baa244e13c33cc803de808818ef1e95a4 (diff)
downloadPeerTube-0f8d00e3144060270d7fe603865fccaf18649c47.tar.gz
PeerTube-0f8d00e3144060270d7fe603865fccaf18649c47.tar.zst
PeerTube-0f8d00e3144060270d7fe603865fccaf18649c47.zip
Implement video comment list in admin
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/sort.ts3
-rw-r--r--server/middlewares/validators/videos/video-comments.ts32
2 files changed, 33 insertions, 2 deletions
diff --git a/server/middlewares/validators/sort.ts b/server/middlewares/validators/sort.ts
index 29aba0436..e93ceb200 100644
--- a/server/middlewares/validators/sort.ts
+++ b/server/middlewares/validators/sort.ts
@@ -10,6 +10,7 @@ const SORTABLE_VIDEOS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS)
10const SORTABLE_VIDEOS_SEARCH_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS_SEARCH) 10const SORTABLE_VIDEOS_SEARCH_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS_SEARCH)
11const SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_CHANNELS_SEARCH) 11const SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_CHANNELS_SEARCH)
12const SORTABLE_VIDEO_IMPORTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_IMPORTS) 12const SORTABLE_VIDEO_IMPORTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_IMPORTS)
13const SORTABLE_VIDEO_COMMENTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS)
13const SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS) 14const SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS)
14const SORTABLE_VIDEO_RATES_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_RATES) 15const SORTABLE_VIDEO_RATES_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_RATES)
15const SORTABLE_BLACKLISTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.BLACKLISTS) 16const SORTABLE_BLACKLISTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.BLACKLISTS)
@@ -33,6 +34,7 @@ const videosSortValidator = checkSort(SORTABLE_VIDEOS_COLUMNS)
33const videoImportsSortValidator = checkSort(SORTABLE_VIDEO_IMPORTS_COLUMNS) 34const videoImportsSortValidator = checkSort(SORTABLE_VIDEO_IMPORTS_COLUMNS)
34const videosSearchSortValidator = checkSort(SORTABLE_VIDEOS_SEARCH_COLUMNS) 35const videosSearchSortValidator = checkSort(SORTABLE_VIDEOS_SEARCH_COLUMNS)
35const videoChannelsSearchSortValidator = checkSort(SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS) 36const videoChannelsSearchSortValidator = checkSort(SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS)
37const videoCommentsValidator = checkSort(SORTABLE_VIDEO_COMMENTS_COLUMNS)
36const videoCommentThreadsSortValidator = checkSort(SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS) 38const videoCommentThreadsSortValidator = checkSort(SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS)
37const videoRatesSortValidator = checkSort(SORTABLE_VIDEO_RATES_COLUMNS) 39const videoRatesSortValidator = checkSort(SORTABLE_VIDEO_RATES_COLUMNS)
38const blacklistSortValidator = checkSort(SORTABLE_BLACKLISTS_COLUMNS) 40const blacklistSortValidator = checkSort(SORTABLE_BLACKLISTS_COLUMNS)
@@ -55,6 +57,7 @@ export {
55 abusesSortValidator, 57 abusesSortValidator,
56 videoChannelsSortValidator, 58 videoChannelsSortValidator,
57 videoImportsSortValidator, 59 videoImportsSortValidator,
60 videoCommentsValidator,
58 videosSearchSortValidator, 61 videosSearchSortValidator,
59 videosSortValidator, 62 videosSortValidator,
60 blacklistSortValidator, 63 blacklistSortValidator,
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts
index 77f5c6ff3..55fb60b98 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 } from '../../../helpers/custom-validators/misc'
6import { 6import {
7 doesVideoCommentExist, 7 doesVideoCommentExist,
8 doesVideoCommentThreadExist, 8 doesVideoCommentThreadExist,
@@ -15,6 +15,33 @@ 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 .custom(isBooleanValid)
22 .withMessage('Should have a valid is local boolean'),
23
24 query('search')
25 .optional()
26 .custom(exists).withMessage('Should have a valid search'),
27
28 query('searchAccount')
29 .optional()
30 .custom(exists).withMessage('Should have a valid account search'),
31
32 query('searchVideo')
33 .optional()
34 .custom(exists).withMessage('Should have a valid video search'),
35
36 (req: express.Request, res: express.Response, next: express.NextFunction) => {
37 logger.debug('Checking listVideoCommentsValidator parameters.', { parameters: req.query })
38
39 if (areValidationErrors(req, res)) return
40
41 return next()
42 }
43]
44
18const listVideoCommentThreadsValidator = [ 45const listVideoCommentThreadsValidator = [
19 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), 46 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
20 47
@@ -116,6 +143,7 @@ export {
116 listVideoCommentThreadsValidator, 143 listVideoCommentThreadsValidator,
117 listVideoThreadCommentsValidator, 144 listVideoThreadCommentsValidator,
118 addVideoCommentThreadValidator, 145 addVideoCommentThreadValidator,
146 listVideoCommentsValidator,
119 addVideoCommentReplyValidator, 147 addVideoCommentReplyValidator,
120 videoCommentGetValidator, 148 videoCommentGetValidator,
121 removeVideoCommentValidator 149 removeVideoCommentValidator