From 754b6f5f41bdc40aaaeefdb3c351666c305abe20 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Tue, 26 Oct 2021 16:42:10 +0200 Subject: 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' --- server/middlewares/validators/videos/video-channels.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'server/middlewares/validators/videos/video-channels.ts') 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 @@ import express from 'express' import { body, param, query } from 'express-validator' -import { VIDEO_CHANNELS } from '@server/initializers/constants' import { MChannelAccountDefault, MUser } from '@server/types/models' import { UserRight } from '../../../../shared' import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' @@ -15,6 +14,7 @@ import { logger } from '../../../helpers/logger' import { ActorModel } from '../../../models/actor/actor' import { VideoChannelModel } from '../../../models/video/video-channel' import { areValidationErrors, doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../shared' +import { CONFIG } from '@server/initializers/config' const videoChannelsAddValidator = [ body('name').custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'), @@ -37,8 +37,8 @@ const videoChannelsAddValidator = [ } const count = await VideoChannelModel.countByAccount(res.locals.oauth.token.User.Account.id) - if (count >= VIDEO_CHANNELS.MAX_PER_USER) { - res.fail({ message: `You cannot create more than ${VIDEO_CHANNELS.MAX_PER_USER} channels` }) + if (count >= CONFIG.VIDEO_CHANNELS.MAX_PER_USER) { + res.fail({ message: `You cannot create more than ${CONFIG.VIDEO_CHANNELS.MAX_PER_USER} channels` }) return false } -- cgit v1.2.3