Add plugin slash command support (#7941)
* add plugin slash command support * remove unused string * rebase
Этот коммит содержится в:
@@ -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)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user