implement GET /commands (#5865)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
67a8770118
Коммит
88b8df3146
@@ -61,7 +61,8 @@ func CreateCommandPost(post *model.Post, teamId string, response *model.CommandR
|
||||
return post, nil
|
||||
}
|
||||
|
||||
func ListCommands(teamId string, T goi18n.TranslateFunc) ([]*model.Command, *model.AppError) {
|
||||
// previous ListCommands now ListAutocompleteCommands
|
||||
func ListAutocompleteCommands(teamId string, T goi18n.TranslateFunc) ([]*model.Command, *model.AppError) {
|
||||
commands := make([]*model.Command, 0, 32)
|
||||
seen := make(map[string]bool)
|
||||
for _, value := range commandProviders {
|
||||
@@ -103,6 +104,36 @@ func ListTeamCommands(teamId string) ([]*model.Command, *model.AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
func ListAllCommands(teamId string, T goi18n.TranslateFunc) ([]*model.Command, *model.AppError) {
|
||||
commands := make([]*model.Command, 0, 32)
|
||||
seen := make(map[string]bool)
|
||||
for _, value := range commandProviders {
|
||||
cpy := *value.GetCommand(T)
|
||||
if cpy.AutoComplete && !seen[cpy.Id] {
|
||||
cpy.Sanitize()
|
||||
seen[cpy.Trigger] = true
|
||||
commands = append(commands, &cpy)
|
||||
}
|
||||
}
|
||||
|
||||
if *utils.Cfg.ServiceSettings.EnableCommands {
|
||||
if result := <-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] {
|
||||
cmd.Sanitize()
|
||||
seen[cmd.Trigger] = true
|
||||
commands = append(commands, cmd)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return commands, nil
|
||||
}
|
||||
|
||||
func ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
|
||||
parts := strings.Split(args.Command, " ")
|
||||
trigger := parts[0][1:]
|
||||
|
||||
Ссылка в новой задаче
Block a user