implement GET /teams/{team_id}/commands/autocomplete (#5951)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
348374fba5
Коммит
0a81dd9fff
@@ -18,6 +18,8 @@ func InitCommand() {
|
||||
|
||||
BaseRoutes.Commands.Handle("", ApiSessionRequired(createCommand)).Methods("POST")
|
||||
BaseRoutes.Commands.Handle("", ApiSessionRequired(listCommands)).Methods("GET")
|
||||
|
||||
BaseRoutes.Team.Handle("/commands/autocomplete", ApiSessionRequired(listAutocompleteCommands)).Methods("GET")
|
||||
}
|
||||
|
||||
func createCommand(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
@@ -91,3 +93,23 @@ func listCommands(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Write([]byte(model.CommandListToJson(commands)))
|
||||
}
|
||||
|
||||
func listAutocompleteCommands(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.RequireTeamId()
|
||||
if c.Err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !app.SessionHasPermissionToTeam(c.Session, c.Params.TeamId, model.PERMISSION_VIEW_TEAM) {
|
||||
c.SetPermissionError(model.PERMISSION_VIEW_TEAM)
|
||||
return
|
||||
}
|
||||
|
||||
commands, err := app.ListAutocompleteCommands(c.Params.TeamId, c.T)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
w.Write([]byte(model.CommandListToJson(commands)))
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user