3 Commits

Author SHA1 Message Date
0a8e68baf4 Remove print statement that was left in by accident... woops! 2020-05-12 18:50:55 -04:00
acc3e3ddec Fix ListConvsOnName 2020-05-12 14:45:50 -04:00
22396f8276 Add ListConvsOnName 2020-05-12 01:39:29 -04:00
2 changed files with 52 additions and 0 deletions

34
chat.go
View File

@ -752,3 +752,37 @@ func (k *Keybase) ListMembersOfConversation(convID chat1.ConvIDStr) (chat1.ChatM
}
return k.ListMembers(opts)
}
// ListConvsOnName returns a list of all conversations for a chat1.ChatChannel
func (k *Keybase) ListConvsOnName(channel chat1.ChatChannel) (*[]chat1.ConvSummary, error) {
type result struct {
Conversations []chat1.ConvSummary `json:"conversations"`
}
type res struct {
Result result `json:"result"`
Error *Error `json:"error,omitempty"`
}
var r res
arg := newListConvsOnNameArg(channel)
jsonBytes, _ := json.Marshal(arg)
cmdOut, err := k.Exec("chat", "api", "-m", string(jsonBytes))
if err != nil {
return nil, err
}
err = json.Unmarshal(cmdOut, &r)
if err != nil {
return nil, err
}
if r.Error != nil {
return nil, fmt.Errorf("%v", r.Error.Message)
}
return &r.Result.Conversations, nil
}

View File

@ -238,6 +238,24 @@ func newListMembersArg(options ListMembersOptions) listMembersArg {
}
}
type listConvsOnNameParams struct {
Options chat1.ChatChannel
}
type listConvsOnNameArg struct {
Method string
Params listConvsOnNameParams
}
func newListConvsOnNameArg(channel chat1.ChatChannel) listConvsOnNameArg {
return listConvsOnNameArg{
Method: "listconvsonname",
Params: listConvsOnNameParams{
Options: channel,
},
}
}
// KVOptions holds a set of options to be passed to the KV methods
type KVOptions struct {
Team *string `json:"team"`