diff options
author | Wim <wim@42.be> | 2017-07-16 14:29:46 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-07-16 14:29:46 +0200 |
commit | aec5e3d77b6e480d04dd8773723de62416a94919 (patch) | |
tree | 57ab269e6c46e62e61db04a9ca6fbb55e736519f /vendor/github.com/nlopes/slack/reactions.go | |
parent | 335ddf8db543bf64522196e6928c3d10af64694c (diff) | |
download | matterbridge-msglm-aec5e3d77b6e480d04dd8773723de62416a94919.tar.gz matterbridge-msglm-aec5e3d77b6e480d04dd8773723de62416a94919.tar.bz2 matterbridge-msglm-aec5e3d77b6e480d04dd8773723de62416a94919.zip |
Update vendor (nlopes/slack)
Diffstat (limited to 'vendor/github.com/nlopes/slack/reactions.go')
-rw-r--r-- | vendor/github.com/nlopes/slack/reactions.go | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/vendor/github.com/nlopes/slack/reactions.go b/vendor/github.com/nlopes/slack/reactions.go index 8769543d..9da59241 100644 --- a/vendor/github.com/nlopes/slack/reactions.go +++ b/vendor/github.com/nlopes/slack/reactions.go @@ -1,6 +1,7 @@ package slack import ( + "context" "errors" "net/url" "strconv" @@ -129,6 +130,11 @@ func (res listReactionsResponseFull) extractReactedItems() []ReactedItem { // AddReaction adds a reaction emoji to a message, file or file comment. func (api *Client) AddReaction(name string, item ItemRef) error { + return api.AddReactionContext(context.Background(), name, item) +} + +// AddReactionContext adds a reaction emoji to a message, file or file comment with a custom context. +func (api *Client) AddReactionContext(ctx context.Context, name string, item ItemRef) error { values := url.Values{ "token": {api.config.token}, } @@ -148,7 +154,7 @@ func (api *Client) AddReaction(name string, item ItemRef) error { values.Set("file_comment", string(item.Comment)) } response := &SlackResponse{} - if err := post("reactions.add", values, response, api.debug); err != nil { + if err := post(ctx, "reactions.add", values, response, api.debug); err != nil { return err } if !response.Ok { @@ -159,6 +165,11 @@ func (api *Client) AddReaction(name string, item ItemRef) error { // RemoveReaction removes a reaction emoji from a message, file or file comment. func (api *Client) RemoveReaction(name string, item ItemRef) error { + return api.RemoveReactionContext(context.Background(), name, item) +} + +// RemoveReactionContext removes a reaction emoji from a message, file or file comment with a custom context. +func (api *Client) RemoveReactionContext(ctx context.Context, name string, item ItemRef) error { values := url.Values{ "token": {api.config.token}, } @@ -178,7 +189,7 @@ func (api *Client) RemoveReaction(name string, item ItemRef) error { values.Set("file_comment", string(item.Comment)) } response := &SlackResponse{} - if err := post("reactions.remove", values, response, api.debug); err != nil { + if err := post(ctx, "reactions.remove", values, response, api.debug); err != nil { return err } if !response.Ok { @@ -189,6 +200,11 @@ func (api *Client) RemoveReaction(name string, item ItemRef) error { // GetReactions returns details about the reactions on an item. func (api *Client) GetReactions(item ItemRef, params GetReactionsParameters) ([]ItemReaction, error) { + return api.GetReactionsContext(context.Background(), item, params) +} + +// GetReactionsContext returns details about the reactions on an item with a custom context +func (api *Client) GetReactionsContext(ctx context.Context, item ItemRef, params GetReactionsParameters) ([]ItemReaction, error) { values := url.Values{ "token": {api.config.token}, } @@ -208,7 +224,7 @@ func (api *Client) GetReactions(item ItemRef, params GetReactionsParameters) ([] values.Set("full", strconv.FormatBool(params.Full)) } response := &getReactionsResponseFull{} - if err := post("reactions.get", values, response, api.debug); err != nil { + if err := post(ctx, "reactions.get", values, response, api.debug); err != nil { return nil, err } if !response.Ok { @@ -219,6 +235,11 @@ func (api *Client) GetReactions(item ItemRef, params GetReactionsParameters) ([] // ListReactions returns information about the items a user reacted to. func (api *Client) ListReactions(params ListReactionsParameters) ([]ReactedItem, *Paging, error) { + return api.ListReactionsContext(context.Background(), params) +} + +// ListReactionsContext returns information about the items a user reacted to with a custom context. +func (api *Client) ListReactionsContext(ctx context.Context, params ListReactionsParameters) ([]ReactedItem, *Paging, error) { values := url.Values{ "token": {api.config.token}, } @@ -235,7 +256,7 @@ func (api *Client) ListReactions(params ListReactionsParameters) ([]ReactedItem, values.Add("full", strconv.FormatBool(params.Full)) } response := &listReactionsResponseFull{} - err := post("reactions.list", values, response, api.debug) + err := post(ctx, "reactions.list", values, response, api.debug) if err != nil { return nil, nil, err } |