Update ChatList() to allow for more filtering

This commit is contained in:
Sam
2019-10-01 22:10:53 -04:00
parent e4cdbc50c9
commit 384478af39
2 changed files with 15 additions and 4 deletions

12
chat.go
View File

@ -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: &params{},
}
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"

View File

@ -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"`
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"`