summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-03-08 10:04:49 -0500
committerHarrison Healey <harrisonmhealey@gmail.com>2016-03-08 10:04:49 -0500
commitc18cac1f713acad4b3e1a3c71c76a77326f9f49e (patch)
treea423fd880e5c9dd748d70c51837d1dbc3b4f13f2 /api
parent93dc7681562a0848294875e2c7c615b3a0ba0fb4 (diff)
parent2f92a94c3ca26f6e175153e0d5b6916579343915 (diff)
downloadchat-c18cac1f713acad4b3e1a3c71c76a77326f9f49e.tar.gz
chat-c18cac1f713acad4b3e1a3c71c76a77326f9f49e.tar.bz2
chat-c18cac1f713acad4b3e1a3c71c76a77326f9f49e.zip
Merge pull request #2374 from mattermost/PLT-2040
PLT-2040 disable executing of commands
Diffstat (limited to 'api')
-rw-r--r--api/command.go29
1 files changed, 19 insertions, 10 deletions
diff --git a/api/command.go b/api/command.go
index 451de2c33..99fd05d7a 100644
--- a/api/command.go
+++ b/api/command.go
@@ -69,16 +69,18 @@ func listCommands(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
- if result := <-Srv.Store.Command().GetByTeam(c.Session.TeamId); result.Err != nil {
- c.Err = result.Err
- return
- } else {
- teamCmds := result.Data.([]*model.Command)
- for _, cmd := range teamCmds {
- if cmd.AutoComplete && !seen[cmd.Id] {
- cmd.Sanitize()
- seen[cmd.Trigger] = true
- commands = append(commands, cmd)
+ if *utils.Cfg.ServiceSettings.EnableCommands {
+ if result := <-Srv.Store.Command().GetByTeam(c.Session.TeamId); result.Err != nil {
+ c.Err = result.Err
+ return
+ } else {
+ teamCmds := result.Data.([]*model.Command)
+ for _, cmd := range teamCmds {
+ if cmd.AutoComplete && !seen[cmd.Id] {
+ cmd.Sanitize()
+ seen[cmd.Trigger] = true
+ commands = append(commands, cmd)
+ }
}
}
}
@@ -114,6 +116,13 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
handleResponse(c, w, response, channelId, provider.GetCommand(c), true)
return
} else {
+
+ if !*utils.Cfg.ServiceSettings.EnableCommands {
+ c.Err = model.NewLocAppError("executeCommand", "api.command.disabled.app_error", nil, "")
+ c.Err.StatusCode = http.StatusNotImplemented
+ return
+ }
+
chanChan := Srv.Store.Channel().Get(channelId)
teamChan := Srv.Store.Team().Get(c.Session.TeamId)
userChan := Srv.Store.User().Get(c.Session.UserId)