PLT-4403 Add server-based channel autocomplete, search and paging (#4585)
* Add more channel paging API * Add channel paging support to client * Add DB channel search functions * Add API for searching more channels * Add more channel search functionality to client * Add API for autocompleting channels * Add channel autocomplete functionality to the client * Move to be deprecated APIs to their own file * Final clean-up * Fixes related to feedback * Localization changes * Add unit as suffix to timeout constants
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
c96ecae6da
Коммит
981ea33b8e
@@ -1164,6 +1164,7 @@ func (c *Client) GetChannel(id, etag string) (*Result, *AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
// SCHEDULED FOR DEPRECATION IN 3.7 - use GetMoreChannelsPage instead
|
||||
func (c *Client) GetMoreChannels(etag string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiGet(c.GetTeamRoute()+"/channels/more", "", etag); err != nil {
|
||||
return nil, err
|
||||
@@ -1174,6 +1175,43 @@ func (c *Client) GetMoreChannels(etag string) (*Result, *AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetMoreChannelsPage will return a page of open channels the user is not in based on
|
||||
// the provided offset and limit. Must be authenticated.
|
||||
func (c *Client) GetMoreChannelsPage(offset int, limit int) (*Result, *AppError) {
|
||||
if r, err := c.DoApiGet(fmt.Sprintf(c.GetTeamRoute()+"/channels/more/%v/%v", offset, limit), "", ""); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), ChannelListFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
// SearchMoreChannels will return a list of open channels the user is not in, that matches
|
||||
// the search criteria provided. Must be authenticated.
|
||||
func (c *Client) SearchMoreChannels(channelSearch ChannelSearch) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost(c.GetTeamRoute()+"/channels/more/search", channelSearch.ToJson()); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), ChannelListFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
// AutocompleteChannels will return a list of open channels that match the provided
|
||||
// string. Must be authenticated.
|
||||
func (c *Client) AutocompleteChannels(term string) (*Result, *AppError) {
|
||||
url := fmt.Sprintf("%s/channels/autocomplete?term=%s", c.GetTeamRoute(), 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), ChannelListFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) GetChannelCounts(etag string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiGet(c.GetTeamRoute()+"/channels/counts", "", etag); err != nil {
|
||||
return nil, err
|
||||
|
||||
Ссылка в новой задаче
Block a user