From aec5e3d77b6e480d04dd8773723de62416a94919 Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 16 Jul 2017 14:29:46 +0200 Subject: Update vendor (nlopes/slack) --- vendor/github.com/nlopes/slack/search.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'vendor/github.com/nlopes/slack/search.go') diff --git a/vendor/github.com/nlopes/slack/search.go b/vendor/github.com/nlopes/slack/search.go index ab3c5dad..0e8d65e2 100644 --- a/vendor/github.com/nlopes/slack/search.go +++ b/vendor/github.com/nlopes/slack/search.go @@ -1,6 +1,7 @@ package slack import ( + "context" "errors" "net/url" "strconv" @@ -80,7 +81,7 @@ func NewSearchParameters() SearchParameters { } } -func (api *Client) _search(path, query string, params SearchParameters, files, messages bool) (response *searchResponseFull, error error) { +func (api *Client) _search(ctx context.Context, path, query string, params SearchParameters, files, messages bool) (response *searchResponseFull, error error) { values := url.Values{ "token": {api.config.token}, "query": {query}, @@ -101,7 +102,7 @@ func (api *Client) _search(path, query string, params SearchParameters, files, m values.Add("page", strconv.Itoa(params.Page)) } response = &searchResponseFull{} - err := post(path, values, response, api.debug) + err := post(ctx, path, values, response, api.debug) if err != nil { return nil, err } @@ -113,7 +114,11 @@ func (api *Client) _search(path, query string, params SearchParameters, files, m } func (api *Client) Search(query string, params SearchParameters) (*SearchMessages, *SearchFiles, error) { - response, err := api._search("search.all", query, params, true, true) + return api.SearchContext(context.Background(), query, params) +} + +func (api *Client) SearchContext(ctx context.Context, query string, params SearchParameters) (*SearchMessages, *SearchFiles, error) { + response, err := api._search(ctx, "search.all", query, params, true, true) if err != nil { return nil, nil, err } @@ -121,7 +126,11 @@ func (api *Client) Search(query string, params SearchParameters) (*SearchMessage } func (api *Client) SearchFiles(query string, params SearchParameters) (*SearchFiles, error) { - response, err := api._search("search.files", query, params, true, false) + return api.SearchFilesContext(context.Background(), query, params) +} + +func (api *Client) SearchFilesContext(ctx context.Context, query string, params SearchParameters) (*SearchFiles, error) { + response, err := api._search(ctx, "search.files", query, params, true, false) if err != nil { return nil, err } @@ -129,7 +138,11 @@ func (api *Client) SearchFiles(query string, params SearchParameters) (*SearchFi } func (api *Client) SearchMessages(query string, params SearchParameters) (*SearchMessages, error) { - response, err := api._search("search.messages", query, params, false, true) + return api.SearchMessagesContext(context.Background(), query, params) +} + +func (api *Client) SearchMessagesContext(ctx context.Context, query string, params SearchParameters) (*SearchMessages, error) { + response, err := api._search(ctx, "search.messages", query, params, false, true) if err != nil { return nil, err } -- cgit v1.2.3