diff --git a/cmd/mattermost/commands/sampledata.go b/cmd/mattermost/commands/sampledata.go index 8fb3efd229..07f21b8d4e 100644 --- a/cmd/mattermost/commands/sampledata.go +++ b/cmd/mattermost/commands/sampledata.go @@ -563,9 +563,18 @@ func createChannelMembership(channelName string, guest bool) app.UserChannelImpo } } +func getSampleTeamName(idx int) string { + for { + name := fmt.Sprintf("%s-%d", fake.Word(), idx) + if !model.IsReservedTeamName(name) { + return name + } + } +} + func createTeam(idx int) app.LineImportData { displayName := fake.Word() - name := fmt.Sprintf("%s-%d", fake.Word(), idx) + name := getSampleTeamName(idx) allowOpenInvite := rand.Intn(2) == 0 description := fake.Paragraph() diff --git a/model/team.go b/model/team.go index ca0f94fee7..381eb8bb9f 100644 --- a/model/team.go +++ b/model/team.go @@ -234,7 +234,6 @@ func IsReservedTeamName(s string) bool { } func IsValidTeamName(s string) bool { - if !IsValidAlphaNum(s) { return false }