diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/config.ts | 3 | ||||
-rw-r--r-- | server/initializers/checker-before-init.ts | 1 | ||||
-rw-r--r-- | server/initializers/config.ts | 3 | ||||
-rw-r--r-- | server/initializers/constants.ts | 5 | ||||
-rw-r--r-- | server/lib/server-config-manager.ts | 3 | ||||
-rw-r--r-- | server/middlewares/validators/config.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/videos/video-channels.ts | 6 | ||||
-rw-r--r-- | server/models/video/video-channel.ts | 5 | ||||
-rw-r--r-- | server/tests/api/check-params/config.ts | 3 | ||||
-rw-r--r-- | server/tests/api/server/config.ts | 7 |
10 files changed, 28 insertions, 10 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 5ea1f67c9..8965cacc9 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -196,6 +196,9 @@ function customConfig (): CustomConfig { | |||
196 | videoQuota: CONFIG.USER.VIDEO_QUOTA, | 196 | videoQuota: CONFIG.USER.VIDEO_QUOTA, |
197 | videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY | 197 | videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY |
198 | }, | 198 | }, |
199 | videoChannels: { | ||
200 | maxPerUser: CONFIG.VIDEO_CHANNELS.MAX_PER_USER | ||
201 | }, | ||
199 | transcoding: { | 202 | transcoding: { |
200 | enabled: CONFIG.TRANSCODING.ENABLED, | 203 | enabled: CONFIG.TRANSCODING.ENABLED, |
201 | allowAdditionalExtensions: CONFIG.TRANSCODING.ALLOW_ADDITIONAL_EXTENSIONS, | 204 | allowAdditionalExtensions: CONFIG.TRANSCODING.ALLOW_ADDITIONAL_EXTENSIONS, |
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index 16dc137c0..72acdd422 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts | |||
@@ -19,6 +19,7 @@ function checkMissedConfig () { | |||
19 | 'storage.redundancy', 'storage.tmp', 'storage.streaming_playlists', 'storage.plugins', | 19 | 'storage.redundancy', 'storage.tmp', 'storage.streaming_playlists', 'storage.plugins', |
20 | 'log.level', | 20 | 'log.level', |
21 | 'user.video_quota', 'user.video_quota_daily', | 21 | 'user.video_quota', 'user.video_quota_daily', |
22 | 'video_channels.max_per_user', | ||
22 | 'csp.enabled', 'csp.report_only', 'csp.report_uri', | 23 | 'csp.enabled', 'csp.report_only', 'csp.report_uri', |
23 | 'security.frameguard.enabled', | 24 | 'security.frameguard.enabled', |
24 | 'cache.previews.size', 'cache.captions.size', 'cache.torrents.size', 'admin.email', 'contact_form.enabled', | 25 | 'cache.previews.size', 'cache.captions.size', 'cache.torrents.size', 'admin.email', 'contact_form.enabled', |
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index cab60a61f..8375bf430 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -233,6 +233,9 @@ const CONFIG = { | |||
233 | get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) }, | 233 | get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) }, |
234 | get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) } | 234 | get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) } |
235 | }, | 235 | }, |
236 | VIDEO_CHANNELS: { | ||
237 | get MAX_PER_USER () { return config.get<number>('video_channels.max_per_user') } | ||
238 | }, | ||
236 | TRANSCODING: { | 239 | TRANSCODING: { |
237 | get ENABLED () { return config.get<boolean>('transcoding.enabled') }, | 240 | get ENABLED () { return config.get<boolean>('transcoding.enabled') }, |
238 | get ALLOW_ADDITIONAL_EXTENSIONS () { return config.get<boolean>('transcoding.allow_additional_extensions') }, | 241 | get ALLOW_ADDITIONAL_EXTENSIONS () { return config.get<boolean>('transcoding.allow_additional_extensions') }, |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index f6c19dab4..3781f9508 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -512,10 +512,6 @@ const OVERVIEWS = { | |||
512 | } | 512 | } |
513 | } | 513 | } |
514 | 514 | ||
515 | const VIDEO_CHANNELS = { | ||
516 | MAX_PER_USER: 20 | ||
517 | } | ||
518 | |||
519 | // --------------------------------------------------------------------------- | 515 | // --------------------------------------------------------------------------- |
520 | 516 | ||
521 | const SERVER_ACTOR_NAME = 'peertube' | 517 | const SERVER_ACTOR_NAME = 'peertube' |
@@ -897,7 +893,6 @@ export { | |||
897 | VIDEO_TRANSCODING_FPS, | 893 | VIDEO_TRANSCODING_FPS, |
898 | FFMPEG_NICE, | 894 | FFMPEG_NICE, |
899 | ABUSE_STATES, | 895 | ABUSE_STATES, |
900 | VIDEO_CHANNELS, | ||
901 | LRU_CACHE, | 896 | LRU_CACHE, |
902 | REQUEST_TIMEOUT, | 897 | REQUEST_TIMEOUT, |
903 | USER_PASSWORD_RESET_LIFETIME, | 898 | USER_PASSWORD_RESET_LIFETIME, |
diff --git a/server/lib/server-config-manager.ts b/server/lib/server-config-manager.ts index b78251e8c..bdf6492f9 100644 --- a/server/lib/server-config-manager.ts +++ b/server/lib/server-config-manager.ts | |||
@@ -184,6 +184,9 @@ class ServerConfigManager { | |||
184 | videoQuota: CONFIG.USER.VIDEO_QUOTA, | 184 | videoQuota: CONFIG.USER.VIDEO_QUOTA, |
185 | videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY | 185 | videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY |
186 | }, | 186 | }, |
187 | videoChannels: { | ||
188 | maxPerUser: CONFIG.VIDEO_CHANNELS.MAX_PER_USER | ||
189 | }, | ||
187 | trending: { | 190 | trending: { |
188 | videos: { | 191 | videos: { |
189 | intervalDays: CONFIG.TRENDING.VIDEOS.INTERVAL_DAYS, | 192 | intervalDays: CONFIG.TRENDING.VIDEOS.INTERVAL_DAYS, |
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 | ||
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 4151dc5b5..b652d8531 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts | |||
@@ -26,7 +26,7 @@ import { | |||
26 | isVideoChannelDisplayNameValid, | 26 | isVideoChannelDisplayNameValid, |
27 | isVideoChannelSupportValid | 27 | isVideoChannelSupportValid |
28 | } from '../../helpers/custom-validators/video-channels' | 28 | } from '../../helpers/custom-validators/video-channels' |
29 | import { CONSTRAINTS_FIELDS, VIDEO_CHANNELS, WEBSERVER } from '../../initializers/constants' | 29 | import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants' |
30 | import { sendDeleteActor } from '../../lib/activitypub/send' | 30 | import { sendDeleteActor } from '../../lib/activitypub/send' |
31 | import { | 31 | import { |
32 | MChannelActor, | 32 | MChannelActor, |
@@ -44,6 +44,7 @@ import { setAsUpdated } from '../shared' | |||
44 | import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' | 44 | import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' |
45 | import { VideoModel } from './video' | 45 | import { VideoModel } from './video' |
46 | import { VideoPlaylistModel } from './video-playlist' | 46 | import { VideoPlaylistModel } from './video-playlist' |
47 | import { CONFIG } from '@server/initializers/config' | ||
47 | 48 | ||
48 | export enum ScopeNames { | 49 | export enum ScopeNames { |
49 | FOR_API = 'FOR_API', | 50 | FOR_API = 'FOR_API', |
@@ -584,7 +585,7 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"` | |||
584 | 585 | ||
585 | static listAllByAccount (accountId: number) { | 586 | static listAllByAccount (accountId: number) { |
586 | const query = { | 587 | const query = { |
587 | limit: VIDEO_CHANNELS.MAX_PER_USER, | 588 | limit: CONFIG.VIDEO_CHANNELS.MAX_PER_USER, |
588 | include: [ | 589 | include: [ |
589 | { | 590 | { |
590 | attributes: [], | 591 | attributes: [], |
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index 87cb2287e..273b1f718 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts | |||
@@ -81,6 +81,9 @@ describe('Test config API validators', function () { | |||
81 | videoQuota: 5242881, | 81 | videoQuota: 5242881, |
82 | videoQuotaDaily: 318742 | 82 | videoQuotaDaily: 318742 |
83 | }, | 83 | }, |
84 | videoChannels: { | ||
85 | maxPerUser: 20 | ||
86 | }, | ||
84 | transcoding: { | 87 | transcoding: { |
85 | enabled: true, | 88 | enabled: true, |
86 | allowAdditionalExtensions: true, | 89 | allowAdditionalExtensions: true, |
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index 1d996d454..8d5b3ac7f 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts | |||
@@ -58,6 +58,8 @@ function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) { | |||
58 | expect(data.user.videoQuota).to.equal(5242880) | 58 | expect(data.user.videoQuota).to.equal(5242880) |
59 | expect(data.user.videoQuotaDaily).to.equal(-1) | 59 | expect(data.user.videoQuotaDaily).to.equal(-1) |
60 | 60 | ||
61 | expect(data.videoChannels.maxPerUser).to.equal(20) | ||
62 | |||
61 | expect(data.transcoding.enabled).to.be.false | 63 | expect(data.transcoding.enabled).to.be.false |
62 | expect(data.transcoding.allowAdditionalExtensions).to.be.false | 64 | expect(data.transcoding.allowAdditionalExtensions).to.be.false |
63 | expect(data.transcoding.allowAudioFiles).to.be.false | 65 | expect(data.transcoding.allowAudioFiles).to.be.false |
@@ -153,6 +155,8 @@ function checkUpdatedConfig (data: CustomConfig) { | |||
153 | expect(data.user.videoQuota).to.equal(5242881) | 155 | expect(data.user.videoQuota).to.equal(5242881) |
154 | expect(data.user.videoQuotaDaily).to.equal(318742) | 156 | expect(data.user.videoQuotaDaily).to.equal(318742) |
155 | 157 | ||
158 | expect(data.videoChannels.maxPerUser).to.equal(24) | ||
159 | |||
156 | expect(data.transcoding.enabled).to.be.true | 160 | expect(data.transcoding.enabled).to.be.true |
157 | expect(data.transcoding.threads).to.equal(1) | 161 | expect(data.transcoding.threads).to.equal(1) |
158 | expect(data.transcoding.concurrency).to.equal(3) | 162 | expect(data.transcoding.concurrency).to.equal(3) |
@@ -265,6 +269,9 @@ const newCustomConfig: CustomConfig = { | |||
265 | videoQuota: 5242881, | 269 | videoQuota: 5242881, |
266 | videoQuotaDaily: 318742 | 270 | videoQuotaDaily: 318742 |
267 | }, | 271 | }, |
272 | videoChannels: { | ||
273 | maxPerUser: 24 | ||
274 | }, | ||
268 | transcoding: { | 275 | transcoding: { |
269 | enabled: true, | 276 | enabled: true, |
270 | allowAdditionalExtensions: true, | 277 | allowAdditionalExtensions: true, |