summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nlopes/slack/conversation.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/nlopes/slack/conversation.go')
-rw-r--r--vendor/github.com/nlopes/slack/conversation.go44
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)