diff options
author | Chris <ccbrown112@gmail.com> | 2017-12-08 13:55:41 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-08 13:55:41 -0600 |
commit | 4c17bdff1bb871fb31520b7b547f584c53ed854f (patch) | |
tree | edf1e3295d6ff7d67281efc585b2e913b4efda3d /app/command.go | |
parent | 7ed1177a2b676aa4c93515268642c855cfe57a37 (diff) | |
download | chat-4c17bdff1bb871fb31520b7b547f584c53ed854f.tar.gz chat-4c17bdff1bb871fb31520b7b547f584c53ed854f.tar.bz2 chat-4c17bdff1bb871fb31520b7b547f584c53ed854f.zip |
Add plugin slash command support (#7941)
* add plugin slash command support
* remove unused string
* rebase
Diffstat (limited to 'app/command.go')
-rw-r--r-- | app/command.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/app/command.go b/app/command.go index dc65de6e2..4c26eae71 100644 --- a/app/command.go +++ b/app/command.go @@ -75,6 +75,13 @@ func (a *App) ListAutocompleteCommands(teamId string, T goi18n.TranslateFunc) ([ } } + for _, cmd := range a.PluginCommandsForTeam(teamId) { + if cmd.AutoComplete && !seen[cmd.Trigger] { + seen[cmd.Trigger] = true + commands = append(commands, cmd) + } + } + if *a.Config().ServiceSettings.EnableCommands { if result := <-a.Srv.Store.Command().GetByTeam(teamId); result.Err != nil { return nil, result.Err @@ -111,7 +118,7 @@ func (a *App) ListAllCommands(teamId string, T goi18n.TranslateFunc) ([]*model.C for _, value := range commandProviders { if cmd := value.GetCommand(a, T); cmd != nil { cpy := *cmd - if cpy.AutoComplete && !seen[cpy.Id] { + if cpy.AutoComplete && !seen[cpy.Trigger] { cpy.Sanitize() seen[cpy.Trigger] = true commands = append(commands, &cpy) @@ -119,13 +126,20 @@ func (a *App) ListAllCommands(teamId string, T goi18n.TranslateFunc) ([]*model.C } } + for _, cmd := range a.PluginCommandsForTeam(teamId) { + if !seen[cmd.Trigger] { + seen[cmd.Trigger] = true + commands = append(commands, cmd) + } + } + if *a.Config().ServiceSettings.EnableCommands { if result := <-a.Srv.Store.Command().GetByTeam(teamId); result.Err != nil { return nil, result.Err } else { teamCmds := result.Data.([]*model.Command) for _, cmd := range teamCmds { - if !seen[cmd.Id] { + if !seen[cmd.Trigger] { cmd.Sanitize() seen[cmd.Trigger] = true commands = append(commands, cmd) @@ -151,6 +165,12 @@ func (a *App) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, * } } + if cmd, response, err := a.ExecutePluginCommand(args); err != nil { + return nil, err + } else if cmd != nil { + return a.HandleCommandResponse(cmd, args, response, true) + } + if !*a.Config().ServiceSettings.EnableCommands { return nil, model.NewAppError("ExecuteCommand", "api.command.disabled.app_error", nil, "", http.StatusNotImplemented) } |