summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lu <david.lu@hotmail.com>2016-05-20 09:14:18 -0400
committerChristopher Speller <crspeller@gmail.com>2016-05-20 09:14:18 -0400
commit981a08e80e3b686210f65c38ee8b8e831ab379e9 (patch)
treeff1e0deb9f7ffb83d2b0b5337fd3eab0fbc07ccc
parent36be959cd96fcc3c7791939e9f4a3e92d737284d (diff)
downloadchat-981a08e80e3b686210f65c38ee8b8e831ab379e9.tar.gz
chat-981a08e80e3b686210f65c38ee8b8e831ab379e9.tar.bz2
chat-981a08e80e3b686210f65c38ee8b8e831ab379e9.zip
Fixed double join messages (#3059)
-rw-r--r--api/command_join.go10
-rw-r--r--api/command_join_test.go13
2 files changed, 2 insertions, 21 deletions
diff --git a/api/command_join.go b/api/command_join.go
index af4443306..a2b1a2ddf 100644
--- a/api/command_join.go
+++ b/api/command_join.go
@@ -42,17 +42,9 @@ func (me *JoinProvider) DoCommand(c *Context, channelId string, message string)
if v.Name == message {
- if v.Type == model.CHANNEL_DIRECT {
+ if v.Type != model.CHANNEL_OPEN {
return &model.CommandResponse{Text: c.T("api.command_join.fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
}
-
- JoinChannelById(c, c.Session.UserId, v.Id)
-
- if c.Err != nil {
- c.Err = nil
- return &model.CommandResponse{Text: c.T("api.command_join.fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
- }
-
return &model.CommandResponse{GotoLocation: c.GetTeamURL() + "/channels/" + v.Name, Text: c.T("api.command_join.success"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
}
}
diff --git a/api/command_join_test.go b/api/command_join_test.go
index 2b4a5bfe3..d586a522a 100644
--- a/api/command_join_test.go
+++ b/api/command_join_test.go
@@ -41,18 +41,7 @@ func TestJoinCommands(t *testing.T) {
c1 := Client.Must(Client.GetChannels("")).Data.(*model.ChannelList)
- if len(c1.Channels) != 6 { // 4 because of town-square, off-topic and direct
- t.Fatal("didn't join channel")
- }
-
- found := false
- for _, c := range c1.Channels {
- if c.Name == channel2.Name {
- found = true
- break
- }
- }
- if !found {
+ if len(c1.Channels) != 5 {
t.Fatal("didn't join channel")
}
}