From 02d581c1599c5d50cc507bd2633f1e3c34b1cc84 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Tue, 29 Nov 2016 10:12:59 -0500 Subject: PLT-4697 Update channel switcher to autocomplete all users on the system (#4624) * Add autocomplete API for system-wide users * Update channel switcher to autocomplete all users on the system --- model/client.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'model/client.go') diff --git a/model/client.go b/model/client.go index 30eba99f8..631de9c56 100644 --- a/model/client.go +++ b/model/client.go @@ -621,6 +621,19 @@ func (c *Client) AutocompleteUsersInTeam(term string) (*Result, *AppError) { } } +// AutocompleteUsers returns a list for autocompletion of users on the system that match the provided term, +// matching against username, full name and nickname. Must be authenticated. +func (c *Client) AutocompleteUsers(term string) (*Result, *AppError) { + url := fmt.Sprintf("/users/autocomplete?term=%s", url.QueryEscape(term)) + if r, err := c.DoApiGet(url, "", ""); err != nil { + return nil, err + } else { + defer closeBody(r) + return &Result{r.Header.Get(HEADER_REQUEST_ID), + r.Header.Get(HEADER_ETAG_SERVER), UserListFromJson(r.Body)}, nil + } +} + // LoginById authenticates a user by user id and password. func (c *Client) LoginById(id string, password string) (*Result, *AppError) { m := make(map[string]string) -- cgit v1.2.3-1-g7c22