summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nlopes/slack/stars.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-07-16 14:29:46 +0200
committerWim <wim@42.be>2017-07-16 14:29:46 +0200
commitaec5e3d77b6e480d04dd8773723de62416a94919 (patch)
tree57ab269e6c46e62e61db04a9ca6fbb55e736519f /vendor/github.com/nlopes/slack/stars.go
parent335ddf8db543bf64522196e6928c3d10af64694c (diff)
downloadmatterbridge-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/stars.go')
-rw-r--r--vendor/github.com/nlopes/slack/stars.go35
1 files changed, 30 insertions, 5 deletions
diff --git a/vendor/github.com/nlopes/slack/stars.go b/vendor/github.com/nlopes/slack/stars.go
index cc12e6ec..cf4a4a11 100644
--- a/vendor/github.com/nlopes/slack/stars.go
+++ b/vendor/github.com/nlopes/slack/stars.go
@@ -1,6 +1,7 @@
package slack
import (
+ "context"
"errors"
"net/url"
"strconv"
@@ -37,6 +38,11 @@ func NewStarsParameters() StarsParameters {
// AddStar stars an item in a channel
func (api *Client) AddStar(channel string, item ItemRef) error {
+ return api.AddStarContext(context.Background(), channel, item)
+}
+
+// AddStarContext stars an item in a channel with a custom context
+func (api *Client) AddStarContext(ctx context.Context, channel string, item ItemRef) error {
values := url.Values{
"channel": {channel},
"token": {api.config.token},
@@ -51,7 +57,7 @@ func (api *Client) AddStar(channel string, item ItemRef) error {
values.Set("file_comment", string(item.Comment))
}
response := &SlackResponse{}
- if err := post("stars.add", values, response, api.debug); err != nil {
+ if err := post(ctx, "stars.add", values, response, api.debug); err != nil {
return err
}
if !response.Ok {
@@ -62,6 +68,11 @@ func (api *Client) AddStar(channel string, item ItemRef) error {
// RemoveStar removes a starred item from a channel
func (api *Client) RemoveStar(channel string, item ItemRef) error {
+ return api.RemoveStarContext(context.Background(), channel, item)
+}
+
+// RemoveStarContext removes a starred item from a channel with a custom context
+func (api *Client) RemoveStarContext(ctx context.Context, channel string, item ItemRef) error {
values := url.Values{
"channel": {channel},
"token": {api.config.token},
@@ -76,7 +87,7 @@ func (api *Client) RemoveStar(channel string, item ItemRef) error {
values.Set("file_comment", string(item.Comment))
}
response := &SlackResponse{}
- if err := post("stars.remove", values, response, api.debug); err != nil {
+ if err := post(ctx, "stars.remove", values, response, api.debug); err != nil {
return err
}
if !response.Ok {
@@ -87,6 +98,11 @@ func (api *Client) RemoveStar(channel string, item ItemRef) error {
// ListStars returns information about the stars a user added
func (api *Client) ListStars(params StarsParameters) ([]Item, *Paging, error) {
+ return api.ListStarsContext(context.Background(), params)
+}
+
+// ListStarsContext returns information about the stars a user added with a custom context
+func (api *Client) ListStarsContext(ctx context.Context, params StarsParameters) ([]Item, *Paging, error) {
values := url.Values{
"token": {api.config.token},
}
@@ -100,7 +116,7 @@ func (api *Client) ListStars(params StarsParameters) ([]Item, *Paging, error) {
values.Add("page", strconv.Itoa(params.Page))
}
response := &listResponseFull{}
- err := post("stars.list", values, response, api.debug)
+ err := post(ctx, "stars.list", values, response, api.debug)
if err != nil {
return nil, nil, err
}
@@ -110,7 +126,9 @@ func (api *Client) ListStars(params StarsParameters) ([]Item, *Paging, error) {
return response.Items, &response.Paging, nil
}
-// GetStarred returns a list of StarredItem items. The user then has to iterate over them and figure out what they should
+// GetStarred returns a list of StarredItem items.
+//
+// The user then has to iterate over them and figure out what they should
// be looking at according to what is in the Type.
// for _, item := range items {
// switch c.Type {
@@ -123,7 +141,14 @@ func (api *Client) ListStars(params StarsParameters) ([]Item, *Paging, error) {
// This function still exists to maintain backwards compatibility.
// I exposed it as returning []StarredItem, so it shall stay as StarredItem
func (api *Client) GetStarred(params StarsParameters) ([]StarredItem, *Paging, error) {
- items, paging, err := api.ListStars(params)
+ return api.GetStarredContext(context.Background(), params)
+}
+
+// GetStarredContext returns a list of StarredItem items with a custom context
+//
+// For more details see GetStarred
+func (api *Client) GetStarredContext(ctx context.Context, params StarsParameters) ([]StarredItem, *Paging, error) {
+ items, paging, err := api.ListStarsContext(ctx, params)
if err != nil {
return nil, nil, err
}