Browse Source

Update ChatList() to allow for more filtering

main
Sam 5 years ago
parent
commit
384478af39
  1. 12
      chat.go
  2. 7
      types.go

12
chat.go

@ -203,13 +203,19 @@ func (c Chat) Delete(messageID int) (ChatAPI, error) { @@ -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"

7
types.go

@ -240,7 +240,12 @@ type options struct { @@ -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"`

Loading…
Cancel
Save