1
0
Fork 0

Allow to change the default channel name (#6000)

* Allow to change the default channel name

* Fix tests

* Fix tests

* Fix tests
This commit is contained in:
Wicklow 2023-10-19 13:22:00 +00:00 committed by GitHub
parent ae468445b2
commit ea6c2b064f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 39 additions and 6 deletions

View file

@ -458,6 +458,7 @@ user:
# -1 == unlimited # -1 == unlimited
video_quota: -1 video_quota: -1
video_quota_daily: -1 video_quota_daily: -1
default_channel_name: 'Main $1 channel' # The placeholder $1 is used to represent the user's username
video_channels: video_channels:
max_per_user: 20 # Allows each user to create up to 20 video channels. max_per_user: 20 # Allows each user to create up to 20 video channels.

View file

@ -468,6 +468,8 @@ user:
# -1 == unlimited # -1 == unlimited
video_quota: -1 video_quota: -1
video_quota_daily: -1 video_quota_daily: -1
default_channel_name: 'Main $1 channel' # The placeholder $1 is used to represent the user's username
video_channels: video_channels:
max_per_user: 20 # Allows each user to create up to 20 video channels. max_per_user: 20 # Allows each user to create up to 20 video channels.

View file

@ -108,6 +108,7 @@ export interface CustomConfig {
} }
videoQuota: number videoQuota: number
videoQuotaDaily: number videoQuotaDaily: number
defaultChannelName: string
} }
videoChannels: { videoChannels: {

View file

@ -428,7 +428,8 @@ export class ConfigCommand extends AbstractCommand {
} }
}, },
videoQuota: 5242881, videoQuota: 5242881,
videoQuotaDaily: 318742 videoQuotaDaily: 318742,
defaultChannelName: 'Main $1 channel'
}, },
videoChannels: { videoChannels: {
maxPerUser: 20 maxPerUser: 20

View file

@ -99,7 +99,8 @@ describe('Test config API validators', function () {
} }
}, },
videoQuota: 5242881, videoQuota: 5242881,
videoQuotaDaily: 318742 videoQuotaDaily: 318742,
defaultChannelName: 'Main $1 channel'
}, },
videoChannels: { videoChannels: {
maxPerUser: 20 maxPerUser: 20

View file

@ -321,7 +321,8 @@ const newCustomConfig: CustomConfig = {
} }
}, },
videoQuota: 5242881, videoQuota: 5242881,
videoQuotaDaily: 318742 videoQuotaDaily: 318742,
defaultChannelName: 'Main $1 channel'
}, },
videoChannels: { videoChannels: {
maxPerUser: 24 maxPerUser: 24

View file

@ -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 () { after(async function () {
for (const sqlCommand of sqlCommands) { for (const sqlCommand of sqlCommands) {
await sqlCommand.cleanup() await sqlCommand.cleanup()

View file

@ -215,7 +215,8 @@ function customConfig (): CustomConfig {
} }
}, },
videoQuota: CONFIG.USER.VIDEO_QUOTA, videoQuota: CONFIG.USER.VIDEO_QUOTA,
videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY,
defaultChannelName: CONFIG.USER.DEFAULT_CHANNEL_NAME
}, },
videoChannels: { videoChannels: {
maxPerUser: CONFIG.VIDEO_CHANNELS.MAX_PER_USER maxPerUser: CONFIG.VIDEO_CHANNELS.MAX_PER_USER

View file

@ -369,7 +369,8 @@ const CONFIG = {
} }
}, },
get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) }, get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) },
get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) } get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) },
get DEFAULT_CHANNEL_NAME () { return config.get<string>('user.default_channel_name') }
}, },
VIDEO_CHANNELS: { VIDEO_CHANNELS: {
get MAX_PER_USER () { return config.get<number>('video_channels.max_per_user') } get MAX_PER_USER () { return config.get<number>('video_channels.max_per_user') }

View file

@ -299,7 +299,7 @@ async function buildChannelAttributes (options: {
if (channelNames) return channelNames if (channelNames) return channelNames
const channelName = await findAvailableLocalActorName(user.username + '_channel', transaction) 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 { return {
name: channelName, name: channelName,