diff options
Diffstat (limited to 'vendor/github.com/nlopes/slack/pins.go')
-rw-r--r-- | vendor/github.com/nlopes/slack/pins.go | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/vendor/github.com/nlopes/slack/pins.go b/vendor/github.com/nlopes/slack/pins.go index b95efbb6..a20f8f73 100644 --- a/vendor/github.com/nlopes/slack/pins.go +++ b/vendor/github.com/nlopes/slack/pins.go @@ -1,6 +1,7 @@ package slack import ( + "context" "errors" "net/url" ) @@ -13,6 +14,11 @@ type listPinsResponseFull struct { // AddPin pins an item in a channel func (api *Client) AddPin(channel string, item ItemRef) error { + return api.AddPinContext(context.Background(), channel, item) +} + +// AddPinContext pins an item in a channel with a custom context +func (api *Client) AddPinContext(ctx context.Context, channel string, item ItemRef) error { values := url.Values{ "channel": {channel}, "token": {api.config.token}, @@ -27,7 +33,7 @@ func (api *Client) AddPin(channel string, item ItemRef) error { values.Set("file_comment", string(item.Comment)) } response := &SlackResponse{} - if err := post("pins.add", values, response, api.debug); err != nil { + if err := post(ctx, "pins.add", values, response, api.debug); err != nil { return err } if !response.Ok { @@ -38,6 +44,11 @@ func (api *Client) AddPin(channel string, item ItemRef) error { // RemovePin un-pins an item from a channel func (api *Client) RemovePin(channel string, item ItemRef) error { + return api.RemovePinContext(context.Background(), channel, item) +} + +// RemovePinContext un-pins an item from a channel with a custom context +func (api *Client) RemovePinContext(ctx context.Context, channel string, item ItemRef) error { values := url.Values{ "channel": {channel}, "token": {api.config.token}, @@ -52,7 +63,7 @@ func (api *Client) RemovePin(channel string, item ItemRef) error { values.Set("file_comment", string(item.Comment)) } response := &SlackResponse{} - if err := post("pins.remove", values, response, api.debug); err != nil { + if err := post(ctx, "pins.remove", values, response, api.debug); err != nil { return err } if !response.Ok { @@ -63,12 +74,17 @@ func (api *Client) RemovePin(channel string, item ItemRef) error { // ListPins returns information about the items a user reacted to. func (api *Client) ListPins(channel string) ([]Item, *Paging, error) { + return api.ListPinsContext(context.Background(), channel) +} + +// ListPinsContext returns information about the items a user reacted to with a custom context. +func (api *Client) ListPinsContext(ctx context.Context, channel string) ([]Item, *Paging, error) { values := url.Values{ "channel": {channel}, "token": {api.config.token}, } response := &listPinsResponseFull{} - err := post("pins.list", values, response, api.debug) + err := post(ctx, "pins.list", values, response, api.debug) if err != nil { return nil, nil, err } |