From 747c562837e37f2fa455e8ef62165e9bb4e365f1 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Tue, 24 Mar 2020 01:12:30 +0100 Subject: Put channel stats behind withStats flag --- server/middlewares/validators/videos/video-channels.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'server/middlewares/validators/videos') diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts index ebce14714..882fb2b84 100644 --- a/server/middlewares/validators/videos/video-channels.ts +++ b/server/middlewares/validators/videos/video-channels.ts @@ -1,5 +1,5 @@ import * as express from 'express' -import { body, param } from 'express-validator' +import { body, param, query } from 'express-validator' import { UserRight } from '../../../../shared' import { isVideoChannelDescriptionValid, @@ -128,6 +128,15 @@ const localVideoChannelValidator = [ } ] +const videoChannelStatsValidator = [ + query('withStats').optional().isBoolean().withMessage('Should have a valid stats flag'), + + (req: express.Request, res: express.Response, next: express.NextFunction) => { + if (areValidationErrors(req, res)) return + return next() + } +] + // --------------------------------------------------------------------------- export { @@ -135,7 +144,8 @@ export { videoChannelsUpdateValidator, videoChannelsRemoveValidator, videoChannelsNameWithHostValidator, - localVideoChannelValidator + localVideoChannelValidator, + videoChannelStatsValidator } // --------------------------------------------------------------------------- -- cgit v1.2.3