diff options
Diffstat (limited to 'vendor/github.com/nlopes/slack/conversation.go')
-rw-r--r-- | vendor/github.com/nlopes/slack/conversation.go | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/vendor/github.com/nlopes/slack/conversation.go b/vendor/github.com/nlopes/slack/conversation.go index 1c64116e..ccd38f88 100644 --- a/vendor/github.com/nlopes/slack/conversation.go +++ b/vendor/github.com/nlopes/slack/conversation.go @@ -99,7 +99,7 @@ func (api *Client) GetUsersInConversationContext(ctx context.Context, params *Ge ResponseMetaData responseMetaData `json:"response_metadata"` SlackResponse }{} - err := postSlackMethod(ctx, api.httpclient, "conversations.members", values, &response, api.debug) + err := postSlackMethod(ctx, api.httpclient, "conversations.members", values, &response, api) if err != nil { return nil, "", err } @@ -118,7 +118,9 @@ func (api *Client) GetConversationsForUser(params *GetConversationsForUserParame func (api *Client) GetConversationsForUserContext(ctx context.Context, params *GetConversationsForUserParameters) (channels []Channel, nextCursor string, err error) { values := url.Values{ "token": {api.token}, - "user": {params.UserID}, + } + if params.UserID != "" { + values.Add("user", params.UserID) } if params.Cursor != "" { values.Add("cursor", params.Cursor) @@ -134,14 +136,12 @@ func (api *Client) GetConversationsForUserContext(ctx context.Context, params *G ResponseMetaData responseMetaData `json:"response_metadata"` SlackResponse }{} - err = postSlackMethod(ctx, api.httpclient, "users.conversations", values, &response, api.debug) + err = postSlackMethod(ctx, api.httpclient, "users.conversations", values, &response, api) if err != nil { return nil, "", err } - if !response.Ok { - return nil, "", errors.New(response.Error) - } - return response.Channels, response.ResponseMetaData.NextCursor, nil + + return response.Channels, response.ResponseMetaData.NextCursor, response.Err() } // ArchiveConversation archives a conversation @@ -156,7 +156,7 @@ func (api *Client) ArchiveConversationContext(ctx context.Context, channelID str "channel": {channelID}, } response := SlackResponse{} - err := postSlackMethod(ctx, api.httpclient, "conversations.archive", values, &response, api.debug) + err := postSlackMethod(ctx, api.httpclient, "conversations.archive", values, &response, api) if err != nil { return err } @@ -176,7 +176,7 @@ func (api *Client) UnArchiveConversationContext(ctx context.Context, channelID s "channel": {channelID}, } response := SlackResponse{} - err := postSlackMethod(ctx, api.httpclient, "conversations.unarchive", values, &response, api.debug) + err := postSlackMethod(ctx, api.httpclient, "conversations.unarchive", values, &response, api) if err != nil { return err } @@ -200,7 +200,7 @@ func (api *Client) SetTopicOfConversationContext(ctx context.Context, channelID, SlackResponse Channel *Channel `json:"channel"` }{} - err := postSlackMethod(ctx, api.httpclient, "conversations.setTopic", values, &response, api.debug) + err := postSlackMethod(ctx, api.httpclient, "conversations.setTopic", values, &response, api) if err != nil { return nil, err } @@ -224,7 +224,7 @@ func (api *Client) SetPurposeOfConversationContext(ctx context.Context, channelI SlackResponse Channel *Channel `json:"channel"` }{} - err := postSlackMethod(ctx, api.httpclient, "conversations.setPurpose", values, &response, api.debug) + err := postSlackMethod(ctx, api.httpclient, "conversations.setPurpose", values, &response, api) if err != nil { return nil, err } @@ -248,7 +248,7 @@ func (api *Client) RenameConversationContext(ctx context.Context, channelID, cha SlackResponse Channel *Channel `json:"channel"` }{} - err := postSlackMethod(ctx, api.httpclient, "conversations.rename", values, &response, api.debug) + err := postSlackMethod(ctx, api.httpclient, "conversations.rename", values, &response, api) if err != nil { return nil, err } @@ -272,7 +272,7 @@ func (api *Client) InviteUsersToConversationContext(ctx context.Context, channel SlackResponse Channel *Channel `json:"channel"` }{} - err := postSlackMethod(ctx, api.httpclient, "conversations.invite", values, &response, api.debug) + err := postSlackMethod(ctx, api.httpclient, "conversations.invite", values, &response, api) if err != nil { return nil, err } @@ -293,7 +293,7 @@ func (api *Client) KickUserFromConversationContext(ctx context.Context, channelI "user": {user}, } response := SlackResponse{} - err := postSlackMethod(ctx, api.httpclient, "conversations.kick", values, &response, api.debug) + err := postSlackMethod(ctx, api.httpclient, "conversations.kick", values, &response, api) if err != nil { return err } @@ -318,7 +318,7 @@ func (api *Client) CloseConversationContext(ctx context.Context, channelID strin AlreadyClosed bool `json:"already_closed"` }{} - err = postSlackMethod(ctx, api.httpclient, "conversations.close", values, &response, api.debug) + err = postSlackMethod(ctx, api.httpclient, "conversations.close", values, &response, api) if err != nil { return false, false, err } @@ -339,7 +339,7 @@ func (api *Client) CreateConversationContext(ctx context.Context, channelName st "is_private": {strconv.FormatBool(isPrivate)}, } response, err := channelRequest( - ctx, api.httpclient, "conversations.create", values, api.debug) + ctx, api.httpclient, "conversations.create", values, api) if err != nil { return nil, err } @@ -360,7 +360,7 @@ func (api *Client) GetConversationInfoContext(ctx context.Context, channelID str "include_locale": {strconv.FormatBool(includeLocale)}, } response, err := channelRequest( - ctx, api.httpclient, "conversations.info", values, api.debug) + ctx, api.httpclient, "conversations.info", values, api) if err != nil { return nil, err } @@ -380,7 +380,7 @@ func (api *Client) LeaveConversationContext(ctx context.Context, channelID strin "channel": {channelID}, } - response, err := channelRequest(ctx, api.httpclient, "conversations.leave", values, api.debug) + response, err := channelRequest(ctx, api.httpclient, "conversations.leave", values, api) if err != nil { return false, err } @@ -436,7 +436,7 @@ func (api *Client) GetConversationRepliesContext(ctx context.Context, params *Ge Messages []Message `json:"messages"` }{} - err = postSlackMethod(ctx, api.httpclient, "conversations.replies", values, &response, api.debug) + err = postSlackMethod(ctx, api.httpclient, "conversations.replies", values, &response, api) if err != nil { return nil, false, "", err } @@ -476,7 +476,7 @@ func (api *Client) GetConversationsContext(ctx context.Context, params *GetConve ResponseMetaData responseMetaData `json:"response_metadata"` SlackResponse }{} - err = postSlackMethod(ctx, api.httpclient, "conversations.list", values, &response, api.debug) + err = postSlackMethod(ctx, api.httpclient, "conversations.list", values, &response, api) if err != nil { return nil, "", err } @@ -513,7 +513,7 @@ func (api *Client) OpenConversationContext(ctx context.Context, params *OpenConv AlreadyOpen bool `json:"already_open"` SlackResponse }{} - err := postSlackMethod(ctx, api.httpclient, "conversations.open", values, &response, api.debug) + err := postSlackMethod(ctx, api.httpclient, "conversations.open", values, &response, api) if err != nil { return nil, false, false, err } @@ -537,7 +537,7 @@ func (api *Client) JoinConversationContext(ctx context.Context, channelID string } `json:"response_metadata"` SlackResponse }{} - err := postSlackMethod(ctx, api.httpclient, "conversations.join", values, &response, api.debug) + err := postSlackMethod(ctx, api.httpclient, "conversations.join", values, &response, api) if err != nil { return nil, "", nil, err } @@ -599,12 +599,10 @@ func (api *Client) GetConversationHistoryContext(ctx context.Context, params *Ge response := GetConversationHistoryResponse{} - err := postSlackMethod(ctx, api.httpclient, "conversations.history", values, &response, api.debug) + err := postSlackMethod(ctx, api.httpclient, "conversations.history", values, &response, api) if err != nil { return nil, err } - if !response.Ok { - return nil, errors.New(response.Error) - } - return &response, nil + + return &response, response.Err() } |