aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/users.ts10
-rw-r--r--server/middlewares/validators/videos.ts45
2 files changed, 26 insertions, 29 deletions
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index 8fbab4dd0..55a08a648 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -118,7 +118,7 @@ const usersUpdateMeValidator = [
118 118
119const usersUpdateMyAvatarValidator = [ 119const usersUpdateMyAvatarValidator = [
120 body('avatarfile').custom((value, { req }) => isAvatarFile(req.files)).withMessage( 120 body('avatarfile').custom((value, { req }) => isAvatarFile(req.files)).withMessage(
121 'This file is not supported. Please, make sure it is of the following type : ' 121 'This file is not supported or too large. Please, make sure it is of the following type : '
122 + CONSTRAINTS_FIELDS.ACTORS.AVATAR.EXTNAME.join(', ') 122 + CONSTRAINTS_FIELDS.ACTORS.AVATAR.EXTNAME.join(', ')
123 ), 123 ),
124 124
@@ -127,14 +127,6 @@ const usersUpdateMyAvatarValidator = [
127 127
128 if (areValidationErrors(req, res)) return 128 if (areValidationErrors(req, res)) return
129 129
130 const imageFile = req.files['avatarfile'][0] as Express.Multer.File
131 if (imageFile.size > CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max) {
132 res.status(400)
133 .send({ error: `The size of the avatar is too big (>${CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max}).` })
134 .end()
135 return
136 }
137
138 return next() 130 return next()
139 } 131 }
140] 132]
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts
index 5595edf17..59d65d5a4 100644
--- a/server/middlewares/validators/videos.ts
+++ b/server/middlewares/validators/videos.ts
@@ -38,18 +38,21 @@ import { authenticate } from '../oauth'
38import { areValidationErrors } from './utils' 38import { areValidationErrors } from './utils'
39 39
40const videosAddValidator = [ 40const videosAddValidator = [
41 body('videofile').custom((value, { req }) => isVideoFile(req.files)).withMessage( 41 body('videofile')
42 'This file is not supported. Please, make sure it is of the following type : ' 42 .custom((value, { req }) => isVideoFile(req.files)).withMessage(
43 + CONSTRAINTS_FIELDS.VIDEOS.EXTNAME.join(', ') 43 'This file is not supported or too large. Please, make sure it is of the following type : '
44 ), 44 + CONSTRAINTS_FIELDS.VIDEOS.EXTNAME.join(', ')
45 body('thumbnailfile').custom((value, { req }) => isVideoImage(req.files, 'thumbnailfile')).withMessage( 45 ),
46 'This thumbnail file is not supported. Please, make sure it is of the following type : ' 46 body('thumbnailfile')
47 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ') 47 .custom((value, { req }) => isVideoImage(req.files, 'thumbnailfile')).withMessage(
48 ), 48 'This thumbnail file is not supported or too large. Please, make sure it is of the following type : '
49 body('previewfile').custom((value, { req }) => isVideoImage(req.files, 'previewfile')).withMessage( 49 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
50 'This preview file is not supported. Please, make sure it is of the following type : ' 50 ),
51 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ') 51 body('previewfile')
52 ), 52 .custom((value, { req }) => isVideoImage(req.files, 'previewfile')).withMessage(
53 'This preview file is not supported or too large. Please, make sure it is of the following type : '
54 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
55 ),
53 body('name').custom(isVideoNameValid).withMessage('Should have a valid name'), 56 body('name').custom(isVideoNameValid).withMessage('Should have a valid name'),
54 body('category') 57 body('category')
55 .optional() 58 .optional()
@@ -147,14 +150,16 @@ const videosAddValidator = [
147 150
148const videosUpdateValidator = [ 151const videosUpdateValidator = [
149 param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), 152 param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
150 body('thumbnailfile').custom((value, { req }) => isVideoImage(req.files, 'thumbnailfile')).withMessage( 153 body('thumbnailfile')
151 'This thumbnail file is not supported. Please, make sure it is of the following type : ' 154 .custom((value, { req }) => isVideoImage(req.files, 'thumbnailfile')).withMessage(
152 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ') 155 'This thumbnail file is not supported or too large. Please, make sure it is of the following type : '
153 ), 156 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
154 body('previewfile').custom((value, { req }) => isVideoImage(req.files, 'previewfile')).withMessage( 157 ),
155 'This preview file is not supported. Please, make sure it is of the following type : ' 158 body('previewfile')
156 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ') 159 .custom((value, { req }) => isVideoImage(req.files, 'previewfile')).withMessage(
157 ), 160 'This preview file is not supported or too large. Please, make sure it is of the following type : '
161 + CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME.join(', ')
162 ),
158 body('name') 163 body('name')
159 .optional() 164 .optional()
160 .custom(isVideoNameValid).withMessage('Should have a valid name'), 165 .custom(isVideoNameValid).withMessage('Should have a valid name'),