diff options
author | Duco van Amstel <duco.vanamstel@gmail.com> | 2018-10-07 22:17:46 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2018-10-07 23:17:46 +0200 |
commit | 917040b044e349eadc886f9685ada30d164687eb (patch) | |
tree | ea063d87a415f89060b376f29a844e4d1ed86363 /vendor/github.com/nlopes/slack/conversation.go | |
parent | 69646a160d8597944c307334901f0acfd32582c5 (diff) | |
download | matterbridge-msglm-917040b044e349eadc886f9685ada30d164687eb.tar.gz matterbridge-msglm-917040b044e349eadc886f9685ada30d164687eb.tar.bz2 matterbridge-msglm-917040b044e349eadc886f9685ada30d164687eb.zip |
Update of nlopes/slack dependency (#511)
Diffstat (limited to 'vendor/github.com/nlopes/slack/conversation.go')
-rw-r--r-- | vendor/github.com/nlopes/slack/conversation.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/vendor/github.com/nlopes/slack/conversation.go b/vendor/github.com/nlopes/slack/conversation.go index edde87a2..1c64116e 100644 --- a/vendor/github.com/nlopes/slack/conversation.go +++ b/vendor/github.com/nlopes/slack/conversation.go @@ -29,6 +29,8 @@ type conversation struct { NameNormalized string `json:"name_normalized"` NumMembers int `json:"num_members"` Priority float64 `json:"priority"` + User string `json:"user"` + // TODO support pending_shared // TODO support previous_names } @@ -64,6 +66,13 @@ type GetUsersInConversationParameters struct { Limit int } +type GetConversationsForUserParameters struct { + UserID string + Cursor string + Types []string + Limit int +} + type responseMetaData struct { NextCursor string `json:"next_cursor"` } @@ -100,6 +109,41 @@ func (api *Client) GetUsersInConversationContext(ctx context.Context, params *Ge return response.Members, response.ResponseMetaData.NextCursor, nil } +// GetConversationsForUser returns the list conversations for a given user +func (api *Client) GetConversationsForUser(params *GetConversationsForUserParameters) (channels []Channel, nextCursor string, err error) { + return api.GetConversationsForUserContext(context.Background(), params) +} + +// GetConversationsForUserContext returns the list conversations for a given user with a custom context +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.Cursor != "" { + values.Add("cursor", params.Cursor) + } + if params.Limit != 0 { + values.Add("limit", strconv.Itoa(params.Limit)) + } + if params.Types != nil { + values.Add("types", strings.Join(params.Types, ",")) + } + response := struct { + Channels []Channel `json:"channels"` + ResponseMetaData responseMetaData `json:"response_metadata"` + SlackResponse + }{} + err = postSlackMethod(ctx, api.httpclient, "users.conversations", values, &response, api.debug) + if err != nil { + return nil, "", err + } + if !response.Ok { + return nil, "", errors.New(response.Error) + } + return response.Channels, response.ResponseMetaData.NextCursor, nil +} + // ArchiveConversation archives a conversation func (api *Client) ArchiveConversation(channelID string) error { return api.ArchiveConversationContext(context.Background(), channelID) |