aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-12 16:01:42 +0200
committerChocobozzz <me@florianbigard.com>2020-06-12 16:27:41 +0200
commit5a61ffbb7c72dd7ecfa16c7944dac45411c1bbe9 (patch)
tree9bc4788c0b54d7386d5533589c6cf52c347c0a48 /server/middlewares
parente74bda21d15300b4653392957e730c5e4eff2af3 (diff)
downloadPeerTube-5a61ffbb7c72dd7ecfa16c7944dac45411c1bbe9.tar.gz
PeerTube-5a61ffbb7c72dd7ecfa16c7944dac45411c1bbe9.tar.zst
PeerTube-5a61ffbb7c72dd7ecfa16c7944dac45411c1bbe9.zip
Optimize views per day in video channels
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/videos/video-channels.ts17
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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { VIDEO_CHANNELS } from '@server/initializers/constants'
4import { MChannelAccountDefault, MUser } from '@server/typings/models'
3import { UserRight } from '../../../../shared' 5import { UserRight } from '../../../../shared'
6import { isActorPreferredUsernameValid } from '../../../helpers/custom-validators/activitypub/actor'
7import { isBooleanValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc'
4import { 8import {
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'
9import { logger } from '../../../helpers/logger' 13import { logger } from '../../../helpers/logger'
14import { doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../../../helpers/middlewares'
15import { ActorModel } from '../../../models/activitypub/actor'
10import { VideoChannelModel } from '../../../models/video/video-channel' 16import { VideoChannelModel } from '../../../models/video/video-channel'
11import { areValidationErrors } from '../utils' 17import { areValidationErrors } from '../utils'
12import { isActorPreferredUsernameValid } from '../../../helpers/custom-validators/activitypub/actor'
13import { ActorModel } from '../../../models/activitypub/actor'
14import { isBooleanValid } from '../../../helpers/custom-validators/misc'
15import { doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../../../helpers/middlewares'
16import { MChannelAccountDefault, MUser } from '@server/typings/models'
17import { VIDEO_CHANNELS } from '@server/initializers/constants'
18 18
19const videoChannelsAddValidator = [ 19const 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
131const videoChannelStatsValidator = [ 131const 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