Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to change the default channel name #6000

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions config/production.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions packages/models/src/server/custom-config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export interface CustomConfig {
}
videoQuota: number
videoQuotaDaily: number
defaultChannelName: string
}

videoChannels: {
Expand Down
3 changes: 2 additions & 1 deletion packages/server-commands/src/server/config-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ export class ConfigCommand extends AbstractCommand {
}
},
videoQuota: 5242881,
videoQuotaDaily: 318742
videoQuotaDaily: 318742,
defaultChannelName: 'Main $1 channel'
},
videoChannels: {
maxPerUser: 20
Expand Down
3 changes: 2 additions & 1 deletion packages/tests/src/api/check-params/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ describe('Test config API validators', function () {
}
},
videoQuota: 5242881,
videoQuotaDaily: 318742
videoQuotaDaily: 318742,
defaultChannelName: 'Main $1 channel'
},
videoChannels: {
maxPerUser: 20
Expand Down
3 changes: 2 additions & 1 deletion packages/tests/src/api/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ const newCustomConfig: CustomConfig = {
}
},
videoQuota: 5242881,
videoQuotaDaily: 318742
videoQuotaDaily: 318742,
defaultChannelName: 'Main $1 channel'
},
videoChannels: {
maxPerUser: 24
Expand Down
24 changes: 24 additions & 0 deletions packages/tests/src/api/videos/video-channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion server/core/controllers/api/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion server/core/initializers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') }
Expand Down
2 changes: 1 addition & 1 deletion server/core/lib/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down