diff options
author | =Corey Hulen <corey@hulen.com> | 2016-03-07 17:24:09 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2016-03-07 17:24:09 -0800 |
commit | 2f92a94c3ca26f6e175153e0d5b6916579343915 (patch) | |
tree | 3ba704910be0f12cf8a9fe09f36777793f54cd8c /api/command.go | |
parent | b001507bedbc3c09fea2921b11e8825002f999cc (diff) | |
download | chat-2f92a94c3ca26f6e175153e0d5b6916579343915.tar.gz chat-2f92a94c3ca26f6e175153e0d5b6916579343915.tar.bz2 chat-2f92a94c3ca26f6e175153e0d5b6916579343915.zip |
PLT-2040 disable executing of commands
Diffstat (limited to 'api/command.go')
-rw-r--r-- | api/command.go | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/api/command.go b/api/command.go index bebe6629c..01988dd52 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)) 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) |