From 2422c46b27790d94fd29a7092170cee5a1b56008 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Feb 2018 14:46:26 +0100 Subject: Implement support field in video and video channel --- server/middlewares/validators/users.ts | 2 ++ server/middlewares/validators/video-channels.ts | 6 ++++-- server/middlewares/validators/videos.ts | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index cba15c8d3..49bc0bb56 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts @@ -7,6 +7,7 @@ import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' import { isAvatarFile, isUserAutoPlayVideoValid, + isUserDescriptionValid, isUserDisplayNSFWValid, isUserPasswordValid, isUserRoleValid, @@ -97,6 +98,7 @@ const usersUpdateValidator = [ ] const usersUpdateMeValidator = [ + body('description').optional().custom(isUserDescriptionValid).withMessage('Should have a valid description'), body('password').optional().custom(isUserPasswordValid).withMessage('Should have a valid password'), body('email').optional().isEmail().withMessage('Should have a valid email attribute'), body('displayNSFW').optional().custom(isUserDisplayNSFWValid).withMessage('Should have a valid display Not Safe For Work attribute'), diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.ts index 86bddde82..fe42105e8 100644 --- a/server/middlewares/validators/video-channels.ts +++ b/server/middlewares/validators/video-channels.ts @@ -5,7 +5,7 @@ import { isAccountIdExist } from '../../helpers/custom-validators/accounts' import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' import { isVideoChannelDescriptionValid, isVideoChannelExist, - isVideoChannelNameValid + isVideoChannelNameValid, isVideoChannelSupportValid } from '../../helpers/custom-validators/video-channels' import { logger } from '../../helpers/logger' import { UserModel } from '../../models/account/user' @@ -27,7 +27,8 @@ const listVideoAccountChannelsValidator = [ const videoChannelsAddValidator = [ body('name').custom(isVideoChannelNameValid).withMessage('Should have a valid name'), - body('description').custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), + body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), + body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'), (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking videoChannelsAdd parameters', { parameters: req.body }) @@ -42,6 +43,7 @@ const videoChannelsUpdateValidator = [ param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), body('name').optional().custom(isVideoChannelNameValid).withMessage('Should have a valid name'), body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), + body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'), async (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking videoChannelsUpdate parameters', { parameters: req.body }) diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts index 6d4fb907b..e91739f81 100644 --- a/server/middlewares/validators/videos.ts +++ b/server/middlewares/validators/videos.ts @@ -14,7 +14,7 @@ import { isVideoLicenceValid, isVideoNameValid, isVideoPrivacyValid, - isVideoRatingTypeValid, + isVideoRatingTypeValid, isVideoSupportValid, isVideoTagsValid } from '../../helpers/custom-validators/videos' import { getDurationFromVideoFile } from '../../helpers/ffmpeg-utils' @@ -46,6 +46,7 @@ const videosAddValidator = [ body('language').optional().custom(isVideoLanguageValid).withMessage('Should have a valid language'), body('nsfw').custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'), body('description').optional().custom(isVideoDescriptionValid).withMessage('Should have a valid description'), + body('support').optional().custom(isVideoSupportValid).withMessage('Should have a valid support text'), body('channelId').custom(isIdValid).withMessage('Should have correct video channel id'), body('privacy').custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'), body('tags').optional().custom(isVideoTagsValid).withMessage('Should have correct tags'), @@ -116,6 +117,7 @@ const videosUpdateValidator = [ body('nsfw').optional().custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'), body('privacy').optional().custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'), body('description').optional().custom(isVideoDescriptionValid).withMessage('Should have a valid description'), + body('support').optional().custom(isVideoSupportValid).withMessage('Should have a valid support text'), body('tags').optional().custom(isVideoTagsValid).withMessage('Should have correct tags'), body('commentsEnabled').optional().custom(isBooleanValid).withMessage('Should have comments enabled boolean'), -- cgit v1.2.3