From 384478af39393203fe6c515bb3ad9fa010e0d482 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 1 Oct 2019 22:10:53 -0400 Subject: [PATCH] Update ChatList() to allow for more filtering --- chat.go | 12 +++++++++--- types.go | 7 ++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/chat.go b/chat.go index 2fa9c10..4d2abf7 100644 --- a/chat.go +++ b/chat.go @@ -203,13 +203,19 @@ func (c Chat) Delete(messageID int) (ChatAPI, error) { } // ChatList returns a list of all conversations. -func (k *Keybase) ChatList(topicType ...string) (ChatAPI, error) { +// You can pass a Channel to use as a filter here, but you'll probably want to +// leave the TopicName empty. +func (k *Keybase) ChatList(opts ...Channel) (ChatAPI, error) { m := ChatAPI{ Params: ¶ms{}, } - if len(topicType) > 0 { - m.Params.Options.TopicType = topicType[0] + if len(opts) > 0 { + m.Params.Options.Name = opts[0].Name + m.Params.Options.Public = opts[0].Public + m.Params.Options.MembersType = opts[0].MembersType + m.Params.Options.TopicType = opts[0].TopicType + m.Params.Options.TopicName = opts[0].TopicName } m.Method = "list" diff --git a/types.go b/types.go index c2f53d2..98eea8d 100644 --- a/types.go +++ b/types.go @@ -240,7 +240,12 @@ type options struct { FlipConversationID string `json:"flip_conversation_id,omitempty"` MsgID int `json:"msg_id,omitempty"` GameID string `json:"game_id,omitempty"` - TopicType string `json:"topic_type,omitempty"` + + Name string `json:"name"` + Public bool `json:"public,omitempty"` + MembersType string `json:"members_type,omitempty"` + TopicType string `json:"topic_type,omitempty"` + TopicName string `json:"topic_name,omitempty"` } type params struct { Options options `json:"options"`