forked from lug/matterbridge
Update vendor (nlopes/slack)
This commit is contained in:
+25
-4
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user