diff --git a/config/default.yaml b/config/default.yaml index 2a0b0fb1c..f4c850911 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -458,6 +458,7 @@ user: # -1 == unlimited video_quota: -1 video_quota_daily: -1 + default_channel_name: 'Main $1 channel' # The placeholder $1 is used to represent the user's username video_channels: max_per_user: 20 # Allows each user to create up to 20 video channels. diff --git a/config/production.yaml.example b/config/production.yaml.example index 5a7f378c4..ed0385542 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example @@ -468,6 +468,8 @@ user: # -1 == unlimited video_quota: -1 video_quota_daily: -1 + default_channel_name: 'Main $1 channel' # The placeholder $1 is used to represent the user's username + video_channels: max_per_user: 20 # Allows each user to create up to 20 video channels. diff --git a/packages/models/src/server/custom-config.model.ts b/packages/models/src/server/custom-config.model.ts index df4176ba7..138ccd8f9 100644 --- a/packages/models/src/server/custom-config.model.ts +++ b/packages/models/src/server/custom-config.model.ts @@ -108,6 +108,7 @@ export interface CustomConfig { } videoQuota: number videoQuotaDaily: number + defaultChannelName: string } videoChannels: { diff --git a/packages/server-commands/src/server/config-command.ts b/packages/server-commands/src/server/config-command.ts index 8fcf0bd51..527a77610 100644 --- a/packages/server-commands/src/server/config-command.ts +++ b/packages/server-commands/src/server/config-command.ts @@ -428,7 +428,8 @@ export class ConfigCommand extends AbstractCommand { } }, videoQuota: 5242881, - videoQuotaDaily: 318742 + videoQuotaDaily: 318742, + defaultChannelName: 'Main $1 channel' }, videoChannels: { maxPerUser: 20 diff --git a/packages/tests/src/api/check-params/config.ts b/packages/tests/src/api/check-params/config.ts index 8179a8815..15b09791d 100644 --- a/packages/tests/src/api/check-params/config.ts +++ b/packages/tests/src/api/check-params/config.ts @@ -99,7 +99,8 @@ describe('Test config API validators', function () { } }, videoQuota: 5242881, - videoQuotaDaily: 318742 + videoQuotaDaily: 318742, + defaultChannelName: 'Main $1 channel' }, videoChannels: { maxPerUser: 20 diff --git a/packages/tests/src/api/server/config.ts b/packages/tests/src/api/server/config.ts index ce64668f8..37beb4597 100644 --- a/packages/tests/src/api/server/config.ts +++ b/packages/tests/src/api/server/config.ts @@ -321,7 +321,8 @@ const newCustomConfig: CustomConfig = { } }, videoQuota: 5242881, - videoQuotaDaily: 318742 + videoQuotaDaily: 318742, + defaultChannelName: 'Main $1 channel' }, videoChannels: { maxPerUser: 24 diff --git a/packages/tests/src/api/videos/video-channels.ts b/packages/tests/src/api/videos/video-channels.ts index c431fc0eb..e43c42e04 100644 --- a/packages/tests/src/api/videos/video-channels.ts +++ b/packages/tests/src/api/videos/video-channels.ts @@ -546,6 +546,30 @@ describe('Test video channels', function () { } }) + it('Should apply another default channel name', async function () { + this.timeout(15000) + + await servers[0].config.updateCustomSubConfig({ + newConfig: { + user: { + defaultChannelName: `$1's channel` + } + } + }) + + await servers[0].users.generate('third_user') + + const body = await servers[0].channels.listByAccount({ accountName: 'third_user' }) + + expect(body.total).to.equal(1) + expect(body.data).to.be.an('array') + expect(body.data).to.have.lengthOf(1) + + const videoChannel = body.data[0] + expect(videoChannel.displayName).to.equal(`third_user's channel`) + expect(videoChannel.name).to.equal('third_user_channel') + }) + after(async function () { for (const sqlCommand of sqlCommands) { await sqlCommand.cleanup() diff --git a/server/core/controllers/api/config.ts b/server/core/controllers/api/config.ts index 58469e97c..b689e5f78 100644 --- a/server/core/controllers/api/config.ts +++ b/server/core/controllers/api/config.ts @@ -215,7 +215,8 @@ function customConfig (): CustomConfig { } }, videoQuota: CONFIG.USER.VIDEO_QUOTA, - videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY + videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY, + defaultChannelName: CONFIG.USER.DEFAULT_CHANNEL_NAME }, videoChannels: { maxPerUser: CONFIG.VIDEO_CHANNELS.MAX_PER_USER diff --git a/server/core/initializers/config.ts b/server/core/initializers/config.ts index 690a20c31..7d0c990a3 100644 --- a/server/core/initializers/config.ts +++ b/server/core/initializers/config.ts @@ -369,7 +369,8 @@ const CONFIG = { } }, get VIDEO_QUOTA () { return parseBytes(config.get('user.video_quota')) }, - get VIDEO_QUOTA_DAILY () { return parseBytes(config.get('user.video_quota_daily')) } + get VIDEO_QUOTA_DAILY () { return parseBytes(config.get('user.video_quota_daily')) }, + get DEFAULT_CHANNEL_NAME () { return config.get('user.default_channel_name') } }, VIDEO_CHANNELS: { get MAX_PER_USER () { return config.get('video_channels.max_per_user') } diff --git a/server/core/lib/user.ts b/server/core/lib/user.ts index d391f384b..5e5970e79 100644 --- a/server/core/lib/user.ts +++ b/server/core/lib/user.ts @@ -299,7 +299,7 @@ async function buildChannelAttributes (options: { if (channelNames) return channelNames const channelName = await findAvailableLocalActorName(user.username + '_channel', transaction) - const videoChannelDisplayName = `Main ${user.username} channel` + const videoChannelDisplayName = CONFIG.USER.DEFAULT_CHANNEL_NAME.replace('$1', user.username) return { name: channelName,