From 06a05d5f4784a7cbb27aa1188385b5679845dad8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Aug 2018 15:25:20 +0200 Subject: Add subscriptions endpoints to REST API --- server/middlewares/validators/video-channels.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'server/middlewares/validators/video-channels.ts') diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.ts index 143ce9582..d354c7e05 100644 --- a/server/middlewares/validators/video-channels.ts +++ b/server/middlewares/validators/video-channels.ts @@ -4,6 +4,7 @@ import { UserRight } from '../../../shared' import { isAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' import { + isLocalVideoChannelNameExist, isVideoChannelDescriptionValid, isVideoChannelExist, isVideoChannelNameValid, @@ -100,6 +101,19 @@ const videoChannelsGetValidator = [ } ] +const localVideoChannelValidator = [ + param('name').custom(isVideoChannelNameValid).withMessage('Should have a valid video channel name'), + + async (req: express.Request, res: express.Response, next: express.NextFunction) => { + logger.debug('Checking localVideoChannelValidator parameters', { parameters: req.params }) + + if (areValidationErrors(req, res)) return + if (!await isLocalVideoChannelNameExist(req.params.name, res)) return + + return next() + } +] + // --------------------------------------------------------------------------- export { @@ -107,7 +121,8 @@ export { videoChannelsAddValidator, videoChannelsUpdateValidator, videoChannelsRemoveValidator, - videoChannelsGetValidator + videoChannelsGetValidator, + localVideoChannelValidator } // --------------------------------------------------------------------------- -- cgit v1.2.3