diff options
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/videos/video-channels.ts | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts index 882fb2b84..6604ae6a8 100644 --- a/server/middlewares/validators/videos/video-channels.ts +++ b/server/middlewares/validators/videos/video-channels.ts | |||
@@ -1,20 +1,20 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { VIDEO_CHANNELS } from '@server/initializers/constants' | ||
4 | import { MChannelAccountDefault, MUser } from '@server/typings/models' | ||
3 | import { UserRight } from '../../../../shared' | 5 | import { UserRight } from '../../../../shared' |
6 | import { isActorPreferredUsernameValid } from '../../../helpers/custom-validators/activitypub/actor' | ||
7 | import { isBooleanValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' | ||
4 | import { | 8 | import { |
5 | isVideoChannelDescriptionValid, | 9 | isVideoChannelDescriptionValid, |
6 | isVideoChannelNameValid, | 10 | isVideoChannelNameValid, |
7 | isVideoChannelSupportValid | 11 | isVideoChannelSupportValid |
8 | } from '../../../helpers/custom-validators/video-channels' | 12 | } from '../../../helpers/custom-validators/video-channels' |
9 | import { logger } from '../../../helpers/logger' | 13 | import { logger } from '../../../helpers/logger' |
14 | import { doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../../../helpers/middlewares' | ||
15 | import { ActorModel } from '../../../models/activitypub/actor' | ||
10 | import { VideoChannelModel } from '../../../models/video/video-channel' | 16 | import { VideoChannelModel } from '../../../models/video/video-channel' |
11 | import { areValidationErrors } from '../utils' | 17 | import { areValidationErrors } from '../utils' |
12 | import { isActorPreferredUsernameValid } from '../../../helpers/custom-validators/activitypub/actor' | ||
13 | import { ActorModel } from '../../../models/activitypub/actor' | ||
14 | import { isBooleanValid } from '../../../helpers/custom-validators/misc' | ||
15 | import { doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../../../helpers/middlewares' | ||
16 | import { MChannelAccountDefault, MUser } from '@server/typings/models' | ||
17 | import { VIDEO_CHANNELS } from '@server/initializers/constants' | ||
18 | 18 | ||
19 | const videoChannelsAddValidator = [ | 19 | const videoChannelsAddValidator = [ |
20 | body('name').custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'), | 20 | body('name').custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'), |
@@ -129,7 +129,10 @@ const localVideoChannelValidator = [ | |||
129 | ] | 129 | ] |
130 | 130 | ||
131 | const videoChannelStatsValidator = [ | 131 | const videoChannelStatsValidator = [ |
132 | query('withStats').optional().isBoolean().withMessage('Should have a valid stats flag'), | 132 | query('withStats') |
133 | .optional() | ||
134 | .customSanitizer(toBooleanOrNull) | ||
135 | .custom(isBooleanValid).withMessage('Should have a valid stats flag'), | ||
133 | 136 | ||
134 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 137 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
135 | if (areValidationErrors(req, res)) return | 138 | if (areValidationErrors(req, res)) return |