diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-09 11:23:14 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-09 11:41:18 +0200 |
commit | 360329cc029c062bfb145c90f7bf1c007c39af81 (patch) | |
tree | a40fb8e31c0d40d65a83e9f0fbc12793230b5c0e /server/middlewares | |
parent | bf696869538eaef27e5a8445035967c01f214501 (diff) | |
download | PeerTube-360329cc029c062bfb145c90f7bf1c007c39af81.tar.gz PeerTube-360329cc029c062bfb145c90f7bf1c007c39af81.tar.zst PeerTube-360329cc029c062bfb145c90f7bf1c007c39af81.zip |
Account/channel descriptions are not required anymore
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/videos.ts | 95 |
1 files changed, 74 insertions, 21 deletions
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts index e3543ef93..b93dccc50 100644 --- a/server/middlewares/validators/videos.ts +++ b/server/middlewares/validators/videos.ts | |||
@@ -2,7 +2,7 @@ import * as express from 'express' | |||
2 | import 'express-validator' | 2 | import 'express-validator' |
3 | import { body, param, query } from 'express-validator/check' | 3 | import { body, param, query } from 'express-validator/check' |
4 | import { UserRight, VideoPrivacy } from '../../../shared' | 4 | import { UserRight, VideoPrivacy } from '../../../shared' |
5 | import { isBooleanValid, isIdOrUUIDValid, isIdValid, isUUIDValid } from '../../helpers/custom-validators/misc' | 5 | import { isBooleanValid, isIdOrUUIDValid, isIdValid, isUUIDValid, toIntOrNull, toStringOrNull } from '../../helpers/custom-validators/misc' |
6 | import { | 6 | import { |
7 | isVideoAbuseReasonValid, | 7 | isVideoAbuseReasonValid, |
8 | isVideoCategoryValid, | 8 | isVideoCategoryValid, |
@@ -14,7 +14,8 @@ import { | |||
14 | isVideoLicenceValid, | 14 | isVideoLicenceValid, |
15 | isVideoNameValid, | 15 | isVideoNameValid, |
16 | isVideoPrivacyValid, | 16 | isVideoPrivacyValid, |
17 | isVideoRatingTypeValid, isVideoSupportValid, | 17 | isVideoRatingTypeValid, |
18 | isVideoSupportValid, | ||
18 | isVideoTagsValid | 19 | isVideoTagsValid |
19 | } from '../../helpers/custom-validators/videos' | 20 | } from '../../helpers/custom-validators/videos' |
20 | import { getDurationFromVideoFile } from '../../helpers/ffmpeg-utils' | 21 | import { getDurationFromVideoFile } from '../../helpers/ffmpeg-utils' |
@@ -41,16 +42,40 @@ const videosAddValidator = [ | |||
41 | + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ') | 42 | + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ') |
42 | ), | 43 | ), |
43 | body('name').custom(isVideoNameValid).withMessage('Should have a valid name'), | 44 | body('name').custom(isVideoNameValid).withMessage('Should have a valid name'), |
44 | body('category').optional().custom(isVideoCategoryValid).withMessage('Should have a valid category'), | 45 | body('category') |
45 | body('licence').optional().custom(isVideoLicenceValid).withMessage('Should have a valid licence'), | 46 | .optional() |
46 | body('language').optional().custom(isVideoLanguageValid).withMessage('Should have a valid language'), | 47 | .customSanitizer(toIntOrNull) |
47 | body('nsfw').custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'), | 48 | .custom(isVideoCategoryValid).withMessage('Should have a valid category'), |
48 | body('description').optional().custom(isVideoDescriptionValid).withMessage('Should have a valid description'), | 49 | body('licence') |
49 | body('support').optional().custom(isVideoSupportValid).withMessage('Should have a valid support text'), | 50 | .optional() |
51 | .customSanitizer(toIntOrNull) | ||
52 | .custom(isVideoLicenceValid).withMessage('Should have a valid licence'), | ||
53 | body('language') | ||
54 | .optional() | ||
55 | .customSanitizer(toStringOrNull) | ||
56 | .custom(isVideoLanguageValid).withMessage('Should have a valid language'), | ||
57 | body('nsfw') | ||
58 | .toBoolean() | ||
59 | .custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'), | ||
60 | body('description') | ||
61 | .optional() | ||
62 | .customSanitizer(toStringOrNull) | ||
63 | .custom(isVideoDescriptionValid).withMessage('Should have a valid description'), | ||
64 | body('support') | ||
65 | .optional() | ||
66 | .customSanitizer(toStringOrNull) | ||
67 | .custom(isVideoSupportValid).withMessage('Should have a valid support text'), | ||
68 | body('tags') | ||
69 | .optional() | ||
70 | .custom(isVideoTagsValid).withMessage('Should have correct tags'), | ||
71 | body('commentsEnabled') | ||
72 | .toBoolean() | ||
73 | .custom(isBooleanValid).withMessage('Should have comments enabled boolean'), | ||
74 | body('privacy') | ||
75 | .optional() | ||
76 | .toInt() | ||
77 | .custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'), | ||
50 | body('channelId').custom(isIdValid).withMessage('Should have correct video channel id'), | 78 | body('channelId').custom(isIdValid).withMessage('Should have correct video channel id'), |
51 | body('privacy').custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'), | ||
52 | body('tags').optional().custom(isVideoTagsValid).withMessage('Should have correct tags'), | ||
53 | body('commentsEnabled').custom(isBooleanValid).withMessage('Should have comments enabled boolean'), | ||
54 | 79 | ||
55 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 80 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
56 | logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files }) | 81 | logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files }) |
@@ -110,16 +135,44 @@ const videosUpdateValidator = [ | |||
110 | 'This preview file is not supported. Please, make sure it is of the following type : ' | 135 | 'This preview file is not supported. Please, make sure it is of the following type : ' |
111 | + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ') | 136 | + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ') |
112 | ), | 137 | ), |
113 | body('name').optional().custom(isVideoNameValid).withMessage('Should have a valid name'), | 138 | body('name') |
114 | body('category').optional().custom(isVideoCategoryValid).withMessage('Should have a valid category'), | 139 | .optional() |
115 | body('licence').optional().custom(isVideoLicenceValid).withMessage('Should have a valid licence'), | 140 | .custom(isVideoNameValid).withMessage('Should have a valid name'), |
116 | body('language').optional().custom(isVideoLanguageValid).withMessage('Should have a valid language'), | 141 | body('category') |
117 | body('nsfw').optional().custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'), | 142 | .optional() |
118 | body('privacy').optional().custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'), | 143 | .customSanitizer(toIntOrNull) |
119 | body('description').optional().custom(isVideoDescriptionValid).withMessage('Should have a valid description'), | 144 | .custom(isVideoCategoryValid).withMessage('Should have a valid category'), |
120 | body('support').optional().custom(isVideoSupportValid).withMessage('Should have a valid support text'), | 145 | body('licence') |
121 | body('tags').optional().custom(isVideoTagsValid).withMessage('Should have correct tags'), | 146 | .optional() |
122 | body('commentsEnabled').optional().custom(isBooleanValid).withMessage('Should have comments enabled boolean'), | 147 | .customSanitizer(toIntOrNull) |
148 | .custom(isVideoLicenceValid).withMessage('Should have a valid licence'), | ||
149 | body('language') | ||
150 | .optional() | ||
151 | .customSanitizer(toStringOrNull) | ||
152 | .custom(isVideoLanguageValid).withMessage('Should have a valid language'), | ||
153 | body('nsfw') | ||
154 | .optional() | ||
155 | .toBoolean() | ||
156 | .custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'), | ||
157 | body('privacy') | ||
158 | .optional() | ||
159 | .toInt() | ||
160 | .custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'), | ||
161 | body('description') | ||
162 | .optional() | ||
163 | .customSanitizer(toStringOrNull) | ||
164 | .custom(isVideoDescriptionValid).withMessage('Should have a valid description'), | ||
165 | body('support') | ||
166 | .optional() | ||
167 | .customSanitizer(toStringOrNull) | ||
168 | .custom(isVideoSupportValid).withMessage('Should have a valid support text'), | ||
169 | body('tags') | ||
170 | .optional() | ||
171 | .custom(isVideoTagsValid).withMessage('Should have correct tags'), | ||
172 | body('commentsEnabled') | ||
173 | .optional() | ||
174 | .toBoolean() | ||
175 | .custom(isBooleanValid).withMessage('Should have comments enabled boolean'), | ||
123 | 176 | ||
124 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 177 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
125 | logger.debug('Checking videosUpdate parameters', { parameters: req.body }) | 178 | logger.debug('Checking videosUpdate parameters', { parameters: req.body }) |