PLT-2040 disable executing of commands

Этот коммит содержится в:
=Corey Hulen
2016-03-07 17:24:09 -08:00
родитель b001507bed
Коммит 2f92a94c3c

Просмотреть файл

@@ -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 { if *utils.Cfg.ServiceSettings.EnableCommands {
c.Err = result.Err if result := <-Srv.Store.Command().GetByTeam(c.Session.TeamId); result.Err != nil {
return c.Err = result.Err
} else { return
teamCmds := result.Data.([]*model.Command) } else {
for _, cmd := range teamCmds { teamCmds := result.Data.([]*model.Command)
if cmd.AutoComplete && !seen[cmd.Id] { for _, cmd := range teamCmds {
cmd.Sanitize() if cmd.AutoComplete && !seen[cmd.Id] {
seen[cmd.Trigger] = true cmd.Sanitize()
commands = append(commands, cmd) 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)) handleResponse(c, w, response, channelId, provider.GetCommand(c))
return return
} else { } 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) chanChan := Srv.Store.Channel().Get(channelId)
teamChan := Srv.Store.Team().Get(c.Session.TeamId) teamChan := Srv.Store.Team().Get(c.Session.TeamId)
userChan := Srv.Store.User().Get(c.Session.UserId) userChan := Srv.Store.User().Get(c.Session.UserId)