From c64959b4395128ec0d60f272281f118bb90cf957 Mon Sep 17 00:00:00 2001 From: Eli Yukelzon Date: Wed, 3 Mar 2021 10:44:18 +0200 Subject: [PATCH] MM-31105 /Join is case sensitive (#16903) Co-authored-by: Mattermod --- api4/commands_test.go | 8 ++++++++ app/slashcommands/command_join.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/api4/commands_test.go b/api4/commands_test.go index 0e2ef926d4..a52323890d 100644 --- a/api4/commands_test.go +++ b/api4/commands_test.go @@ -8,6 +8,7 @@ import ( "testing" "time" + _ "github.com/mattermost/mattermost-server/v5/app/slashcommands" "github.com/stretchr/testify/require" "github.com/mattermost/mattermost-server/v5/model" @@ -128,6 +129,13 @@ func testJoinCommands(t *testing.T, alias string) { } } require.True(t, found, "did not join channel") + + // test case insensitively + channel4 := &model.Channel{DisplayName: "BB", Name: "bb" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id} + channel4 = Client.Must(Client.CreateChannel(channel4)).(*model.Channel) + Client.Must(Client.RemoveUserFromChannel(channel4.Id, th.BasicUser.Id)) + rs7 := Client.Must(Client.ExecuteCommand(channel0.Id, "/"+alias+" "+strings.ToUpper(channel4.Name))).(*model.CommandResponse) + require.True(t, strings.HasSuffix(rs7.GotoLocation, "/"+team.Name+"/channels/"+channel4.Name), "failed to join channel") } func TestJoinCommands(t *testing.T) { diff --git a/app/slashcommands/command_join.go b/app/slashcommands/command_join.go index 3765064fc4..af5234cc12 100644 --- a/app/slashcommands/command_join.go +++ b/app/slashcommands/command_join.go @@ -37,7 +37,7 @@ func (*JoinProvider) GetCommand(a *app.App, T i18n.TranslateFunc) *model.Command } func (*JoinProvider) DoCommand(a *app.App, args *model.CommandArgs, message string) *model.CommandResponse { - channelName := message + channelName := strings.ToLower(message) if strings.HasPrefix(message, "~") { channelName = message[1:]