MM-31105 /Join <channel name> is case sensitive (#16903)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
Eli Yukelzon
2021-03-03 10:44:18 +02:00
committed by GitHub
parent 23d51ed1f2
commit c64959b439
2 changed files with 9 additions and 1 deletions

View File

@@ -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) {

View File

@@ -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:]