Update nlopes/slack vendor

This commit is contained in:
Wim
2018-08-10 00:38:19 +02:00
parent 51062863a5
commit 68aeb93afa
57 changed files with 2654 additions and 2047 deletions

View File

@@ -136,31 +136,30 @@ func (api *Client) AddReaction(name string, item ItemRef) error {
// 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},
"token": {api.token},
}
if name != "" {
values.Set("name", name)
}
if item.Channel != "" {
values.Set("channel", string(item.Channel))
values.Set("channel", item.Channel)
}
if item.Timestamp != "" {
values.Set("timestamp", string(item.Timestamp))
values.Set("timestamp", item.Timestamp)
}
if item.File != "" {
values.Set("file", string(item.File))
values.Set("file", item.File)
}
if item.Comment != "" {
values.Set("file_comment", string(item.Comment))
values.Set("file_comment", item.Comment)
}
response := &SlackResponse{}
if err := post(ctx, "reactions.add", values, response, api.debug); err != nil {
if err := postSlackMethod(ctx, api.httpclient, "reactions.add", values, response, api.debug); err != nil {
return err
}
if !response.Ok {
return errors.New(response.Error)
}
return nil
return response.Err()
}
// RemoveReaction removes a reaction emoji from a message, file or file comment.
@@ -171,31 +170,30 @@ func (api *Client) RemoveReaction(name string, item ItemRef) error {
// 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},
"token": {api.token},
}
if name != "" {
values.Set("name", name)
}
if item.Channel != "" {
values.Set("channel", string(item.Channel))
values.Set("channel", item.Channel)
}
if item.Timestamp != "" {
values.Set("timestamp", string(item.Timestamp))
values.Set("timestamp", item.Timestamp)
}
if item.File != "" {
values.Set("file", string(item.File))
values.Set("file", item.File)
}
if item.Comment != "" {
values.Set("file_comment", string(item.Comment))
values.Set("file_comment", item.Comment)
}
response := &SlackResponse{}
if err := post(ctx, "reactions.remove", values, response, api.debug); err != nil {
if err := postSlackMethod(ctx, api.httpclient, "reactions.remove", values, response, api.debug); err != nil {
return err
}
if !response.Ok {
return errors.New(response.Error)
}
return nil
return response.Err()
}
// GetReactions returns details about the reactions on an item.
@@ -206,25 +204,26 @@ func (api *Client) GetReactions(item ItemRef, params GetReactionsParameters) ([]
// 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},
"token": {api.token},
}
if item.Channel != "" {
values.Set("channel", string(item.Channel))
values.Set("channel", item.Channel)
}
if item.Timestamp != "" {
values.Set("timestamp", string(item.Timestamp))
values.Set("timestamp", item.Timestamp)
}
if item.File != "" {
values.Set("file", string(item.File))
values.Set("file", item.File)
}
if item.Comment != "" {
values.Set("file_comment", string(item.Comment))
values.Set("file_comment", item.Comment)
}
if params.Full != DEFAULT_REACTIONS_FULL {
values.Set("full", strconv.FormatBool(params.Full))
}
response := &getReactionsResponseFull{}
if err := post(ctx, "reactions.get", values, response, api.debug); err != nil {
if err := postSlackMethod(ctx, api.httpclient, "reactions.get", values, response, api.debug); err != nil {
return nil, err
}
if !response.Ok {
@@ -241,7 +240,7 @@ func (api *Client) ListReactions(params ListReactionsParameters) ([]ReactedItem,
// 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},
"token": {api.token},
}
if params.User != DEFAULT_REACTIONS_USER {
values.Add("user", params.User)
@@ -255,8 +254,9 @@ func (api *Client) ListReactionsContext(ctx context.Context, params ListReaction
if params.Full != DEFAULT_REACTIONS_FULL {
values.Add("full", strconv.FormatBool(params.Full))
}
response := &listReactionsResponseFull{}
err := post(ctx, "reactions.list", values, response, api.debug)
err := postSlackMethod(ctx, api.httpclient, "reactions.list", values, response, api.debug)
if err != nil {
return nil, nil, err
}