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:
parent
ae468445b2
commit
ea6c2b064f
10 changed files with 39 additions and 6 deletions
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -108,6 +108,7 @@ export interface CustomConfig {
|
|||
}
|
||||
videoQuota: number
|
||||
videoQuotaDaily: number
|
||||
defaultChannelName: string
|
||||
}
|
||||
|
||||
videoChannels: {
|
||||
|
|
|
@ -428,7 +428,8 @@ export class ConfigCommand extends AbstractCommand {
|
|||
}
|
||||
},
|
||||
videoQuota: 5242881,
|
||||
videoQuotaDaily: 318742
|
||||
videoQuotaDaily: 318742,
|
||||
defaultChannelName: 'Main $1 channel'
|
||||
},
|
||||
videoChannels: {
|
||||
maxPerUser: 20
|
||||
|
|
|
@ -99,7 +99,8 @@ describe('Test config API validators', function () {
|
|||
}
|
||||
},
|
||||
videoQuota: 5242881,
|
||||
videoQuotaDaily: 318742
|
||||
videoQuotaDaily: 318742,
|
||||
defaultChannelName: 'Main $1 channel'
|
||||
},
|
||||
videoChannels: {
|
||||
maxPerUser: 20
|
||||
|
|
|
@ -321,7 +321,8 @@ const newCustomConfig: CustomConfig = {
|
|||
}
|
||||
},
|
||||
videoQuota: 5242881,
|
||||
videoQuotaDaily: 318742
|
||||
videoQuotaDaily: 318742,
|
||||
defaultChannelName: 'Main $1 channel'
|
||||
},
|
||||
videoChannels: {
|
||||
maxPerUser: 24
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -369,7 +369,8 @@ const CONFIG = {
|
|||
}
|
||||
},
|
||||
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: {
|
||||
get MAX_PER_USER () { return config.get<number>('video_channels.max_per_user') }
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue