summaryrefslogtreecommitdiffstats
path: root/app/command_mute.go
diff options
context:
space:
mode:
authorElias Nahum <nahumhbl@gmail.com>2018-04-02 18:58:39 +0300
committerChristopher Speller <crspeller@gmail.com>2018-04-02 08:58:39 -0700
commitcffb8918544aaaabbeccd3a84ab5173fee7b18c8 (patch)
tree564130f71fa9d12b9bae3407884a1c1266f2a79b /app/command_mute.go
parentcf1688f94a6b7bb8c7f1f9f7ce61553bdec13991 (diff)
downloadchat-cffb8918544aaaabbeccd3a84ab5173fee7b18c8.tar.gz
chat-cffb8918544aaaabbeccd3a84ab5173fee7b18c8.tar.bz2
chat-cffb8918544aaaabbeccd3a84ab5173fee7b18c8.zip
Make channel mute command respond with and without ~ prefix (#8549)
* Make channel mute command respond with and without ~ prefix * Re-use splitMessage
Diffstat (limited to 'app/command_mute.go')
-rw-r--r--app/command_mute.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/app/command_mute.go b/app/command_mute.go
index 072e79f92..fdc698cd9 100644
--- a/app/command_mute.go
+++ b/app/command_mute.go
@@ -43,14 +43,20 @@ func (me *MuteProvider) DoCommand(a *App, args *model.CommandArgs, message strin
return &model.CommandResponse{Text: args.T("api.command_mute.error", map[string]interface{}{"Channel": channel.DisplayName}), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
}
+ channelName := ""
+ splitMessage := strings.Split(message, " ")
// Overwrite channel with channel-handle if set
if strings.HasPrefix(message, "~") {
- splitMessage := strings.Split(message, " ")
- chanHandle := strings.Split(splitMessage[0], "~")[1]
- data := (<-a.Srv.Store.Channel().GetByName(channel.TeamId, chanHandle, true)).Data
+ channelName = splitMessage[0][1:]
+ } else {
+ channelName = splitMessage[0]
+ }
+
+ if len(channelName) > 0 && len(message) > 0 {
+ data := (<-a.Srv.Store.Channel().GetByName(channel.TeamId, channelName, true)).Data
if data == nil {
- return &model.CommandResponse{Text: args.T("api.command_mute.error", map[string]interface{}{"Channel": chanHandle}), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
+ return &model.CommandResponse{Text: args.T("api.command_mute.error", map[string]interface{}{"Channel": channelName}), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
}
channel = data.(*model.Channel)