seed a new team with #general and #random

Slack's names, which is what people expect to find when they arrive. The
channel names and their display names move together: town-square -> general,
off-topic -> random.

The name list existed twice, verbatim, in App.DefaultChannelNames and
TeamService.DefaultChannelNames, with a third copy of the literals in the web
app's constants and a fourth in the display-name map. All four now read
model.DefaultChannelName / model.RandomChannelName, so the server and the
client cannot drift apart about which channel a member may not leave.

Existing teams keep the channels they already have -- these constants are read
when a team is created, not on boot, so nothing is renamed underneath anyone.
This commit is contained in:
zooqueen
2026-08-14 23:32:17 -07:00
parent 8ffe414703
commit 6e187bbd5d
9 changed files with 28 additions and 25 deletions
+6 -6
View File
@@ -32,19 +32,19 @@ const (
//
// By default the list will be (not necessarily in this order):
//
// ['town-square', 'off-topic']
// ['general', 'random']
//
// However, if TeamSettings.ExperimentalDefaultChannels contains a list of channels then that list will replace
// 'off-topic' and be included in the return results in addition to 'town-square'. For example:
// 'random' and be included in the return results in addition to 'general'. For example:
//
// ['town-square', 'game-of-thrones', 'wow']
// ['general', 'game-of-thrones', 'wow']
func (a *App) DefaultChannelNames(rctx request.CTX) []string {
names := []string{"town-square"}
names := []string{model.DefaultChannelName}
if len(a.Config().TeamSettings.ExperimentalDefaultChannels) == 0 {
names = append(names, "off-topic")
names = append(names, model.RandomChannelName)
} else {
seenChannels := map[string]bool{"town-square": true}
seenChannels := map[string]bool{model.DefaultChannelName: true}
for _, channelName := range a.Config().TeamSettings.ExperimentalDefaultChannels {
if !seenChannels[channelName] {
names = append(names, channelName)
+2 -2
View File
@@ -1928,7 +1928,7 @@ func TestDefaultChannelNames(t *testing.T) {
th := Setup(t)
actual := th.App.DefaultChannelNames(th.Context)
expect := []string{"town-square", "off-topic"}
expect := []string{"general", "random"}
require.ElementsMatch(t, expect, actual)
th.App.UpdateConfig(func(cfg *model.Config) {
@@ -1936,7 +1936,7 @@ func TestDefaultChannelNames(t *testing.T) {
})
actual = th.App.DefaultChannelNames(th.Context)
expect = []string{"town-square", "foo", "bar"}
expect = []string{"general", "foo", "bar"}
require.ElementsMatch(t, expect, actual)
}
+2 -2
View File
@@ -48,8 +48,8 @@ func (ts *TeamService) GetTeams(teamIDs []string) ([]*model.Team, error) {
// CreateDefaultChannels creates channels in the given team for each channel returned by (*App).DefaultChannelNames.
func (ts *TeamService) createDefaultChannels(rctx request.CTX, teamID string) ([]*model.Channel, error) {
displayNames := map[string]string{
"town-square": i18n.T("api.channel.create_default_channels.town_square"),
"off-topic": i18n.T("api.channel.create_default_channels.off_topic"),
model.DefaultChannelName: i18n.T("api.channel.create_default_channels.town_square"),
model.RandomChannelName: i18n.T("api.channel.create_default_channels.off_topic"),
}
channels := []*model.Channel{}
defaultChannelNames := ts.DefaultChannelNames()
+6 -6
View File
@@ -12,19 +12,19 @@ import (
// By default the list will be (not necessarily in this order):
//
// ['town-square', 'off-topic']
// ['general', 'random']
//
// However, if TeamSettings.ExperimentalDefaultChannels contains a list of channels then that list will replace
// 'off-topic' and be included in the return results in addition to 'town-square'. For example:
// 'random' and be included in the return results in addition to 'general'. For example:
//
// ['town-square', 'game-of-thrones', 'wow']
// ['general', 'game-of-thrones', 'wow']
func (ts *TeamService) DefaultChannelNames() []string {
names := []string{"town-square"}
names := []string{model.DefaultChannelName}
if len(ts.config().TeamSettings.ExperimentalDefaultChannels) == 0 {
names = append(names, "off-topic")
names = append(names, model.RandomChannelName)
} else {
seenChannels := map[string]bool{"town-square": true}
seenChannels := map[string]bool{model.DefaultChannelName: true}
for _, channelName := range ts.config().TeamSettings.ExperimentalDefaultChannels {
if !seenChannels[channelName] {
names = append(names, channelName)
@@ -91,7 +91,7 @@ func ManualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
return
}
channel := &model.Channel{DisplayName: "Town Square", Name: "town-square", Type: model.ChannelTypeOpen, TeamId: createdTeam.Id}
channel := &model.Channel{DisplayName: "general", Name: model.DefaultChannelName, Type: model.ChannelTypeOpen, TeamId: createdTeam.Id}
if _, err := c.App.CreateChannel(c.AppContext, channel, false); err != nil {
c.Err = err
return
+2 -2
View File
@@ -405,11 +405,11 @@
},
{
"id": "api.channel.create_default_channels.off_topic",
"translation": "Off-Topic"
"translation": "random"
},
{
"id": "api.channel.create_default_channels.town_square",
"translation": "Town Square"
"translation": "general"
},
{
"id": "api.channel.create_direct_channel.invalid_user.app_error",
+2 -1
View File
@@ -37,7 +37,8 @@ const (
ChannelGroupMaxUsers = 8
ChannelGroupMinUsers = 3
DefaultChannelName = "town-square"
DefaultChannelName = "general"
RandomChannelName = "random"
ChannelDisplayNameMaxRunes = 64
ChannelNameMinLength = 1
ChannelNameMaxLength = 64
@@ -17,6 +17,8 @@ import {generateId} from 'mattermost-redux/utils/helpers';
import {switchToChannel} from 'actions/views/channel';
import {getLastViewedChannelNameByTeamName} from 'selectors/local_storage';
import Constants from 'utils/constants';
import type {GlobalState} from 'types/store';
interface MatchParams {
@@ -38,7 +40,7 @@ const PlaybookRunner = () => {
useEffect(() => {
const switchToChannelAndStartRun = async () => {
const channelToSwitchTo = lastViewedChannel ?? await Client4.getChannelByName(team?.id || '', 'town-square');
const channelToSwitchTo = lastViewedChannel ?? await Client4.getChannelByName(team?.id || '', Constants.DEFAULT_CHANNEL);
dispatch(switchToChannel(channelToSwitchTo));
dispatch(startPlaybookRunById(channelToSwitchTo, team?.id || '', playbookId));
+4 -4
View File
@@ -1550,10 +1550,10 @@ export const Constants = {
POST_MODAL_PADDING: 170,
SCROLL_DELAY: 2000,
SCROLL_PAGE_FRACTION: 3,
DEFAULT_CHANNEL: 'town-square',
DEFAULT_CHANNEL_UI_NAME: 'Town Square',
OFFTOPIC_CHANNEL: 'off-topic',
OFFTOPIC_CHANNEL_UI_NAME: 'Off-Topic',
DEFAULT_CHANNEL: 'general',
DEFAULT_CHANNEL_UI_NAME: 'general',
OFFTOPIC_CHANNEL: 'random',
OFFTOPIC_CHANNEL_UI_NAME: 'random',
HANZO_SERVICE: 'hanzo',
GOOGLE_SERVICE: 'google',
OFFICE365_SERVICE: 'office365',