diff options
author | Florian CUNY <poslovitch@bentobox.world> | 2021-10-26 16:42:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-26 16:42:10 +0200 |
commit | 754b6f5f41bdc40aaaeefdb3c351666c305abe20 (patch) | |
tree | d36c8081f3137f1e2c9763879f71d41aa9a3efc1 /server/middlewares/validators | |
parent | 615836dbd4f48fc563551446529fa9d3b14dc329 (diff) | |
download | PeerTube-754b6f5f41bdc40aaaeefdb3c351666c305abe20.tar.gz PeerTube-754b6f5f41bdc40aaaeefdb3c351666c305abe20.tar.zst PeerTube-754b6f5f41bdc40aaaeefdb3c351666c305abe20.zip |
Made the video channels limit (per user) server-wide configurable (#4491)
* Made the video channels limit (per user) server-wide configurable
Implements https://github.com/Chocobozzz/PeerTube/issues/3092
Also added a "quota bar" in the account's settings page
* Fixed lint errors
* Another pass at fixing lint errors
* Applied code suggestions
* Removed 'video channels quota'
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/config.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/videos/video-channels.ts | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts index f0385ab44..da52b14ba 100644 --- a/server/middlewares/validators/config.ts +++ b/server/middlewares/validators/config.ts | |||
@@ -38,6 +38,8 @@ const customConfigUpdateValidator = [ | |||
38 | body('user.videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid video quota'), | 38 | body('user.videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid video quota'), |
39 | body('user.videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily video quota'), | 39 | body('user.videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily video quota'), |
40 | 40 | ||
41 | body('videoChannels.maxPerUser').isInt().withMessage("Should have a valid maximum amount of video channels per user"), | ||
42 | |||
41 | body('transcoding.enabled').isBoolean().withMessage('Should have a valid transcoding enabled boolean'), | 43 | body('transcoding.enabled').isBoolean().withMessage('Should have a valid transcoding enabled boolean'), |
42 | body('transcoding.allowAdditionalExtensions').isBoolean().withMessage('Should have a valid additional extensions boolean'), | 44 | body('transcoding.allowAdditionalExtensions').isBoolean().withMessage('Should have a valid additional extensions boolean'), |
43 | body('transcoding.threads').isInt().withMessage('Should have a valid transcoding threads number'), | 45 | body('transcoding.threads').isInt().withMessage('Should have a valid transcoding threads number'), |
diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts index c4705192a..edce48c7f 100644 --- a/server/middlewares/validators/videos/video-channels.ts +++ b/server/middlewares/validators/videos/video-channels.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import express from 'express' | 1 | import 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/types/models' | 3 | import { MChannelAccountDefault, MUser } from '@server/types/models' |
5 | import { UserRight } from '../../../../shared' | 4 | import { UserRight } from '../../../../shared' |
6 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 5 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
@@ -15,6 +14,7 @@ import { logger } from '../../../helpers/logger' | |||
15 | import { ActorModel } from '../../../models/actor/actor' | 14 | import { ActorModel } from '../../../models/actor/actor' |
16 | import { VideoChannelModel } from '../../../models/video/video-channel' | 15 | import { VideoChannelModel } from '../../../models/video/video-channel' |
17 | import { areValidationErrors, doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../shared' | 16 | import { areValidationErrors, doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../shared' |
17 | import { CONFIG } from '@server/initializers/config' | ||
18 | 18 | ||
19 | const videoChannelsAddValidator = [ | 19 | const videoChannelsAddValidator = [ |
20 | body('name').custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'), | 20 | body('name').custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'), |
@@ -37,8 +37,8 @@ const videoChannelsAddValidator = [ | |||
37 | } | 37 | } |
38 | 38 | ||
39 | const count = await VideoChannelModel.countByAccount(res.locals.oauth.token.User.Account.id) | 39 | const count = await VideoChannelModel.countByAccount(res.locals.oauth.token.User.Account.id) |
40 | if (count >= VIDEO_CHANNELS.MAX_PER_USER) { | 40 | if (count >= CONFIG.VIDEO_CHANNELS.MAX_PER_USER) { |
41 | res.fail({ message: `You cannot create more than ${VIDEO_CHANNELS.MAX_PER_USER} channels` }) | 41 | res.fail({ message: `You cannot create more than ${CONFIG.VIDEO_CHANNELS.MAX_PER_USER} channels` }) |
42 | return false | 42 | return false |
43 | } | 43 | } |
44 | 44 | ||