Add ListConvsOnName

This commit is contained in:
2020-05-12 01:39:29 -04:00
parent c9a2bd80bc
commit 22396f8276

35
chat.go
View File

@ -752,3 +752,38 @@ 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 res struct {
Result []chat1.ConvSummary `json:"result"`
Error *Error `json:"error,omitempty"`
}
var r res
opts := SendMessageOptions{
Channel: channel,
}
arg := newSendMessageArg(opts)
arg.Method = "listconvsonname"
jsonBytes, _ := json.Marshal(arg)
cmdOut, err := k.Exec("chat", "api", "-m", string(jsonBytes))
if err != nil {
return r.Result, err
}
err = json.Unmarshal(cmdOut, &r)
if err != nil {
return r.Result, err
}
if r.Error != nil {
return r.Result, fmt.Errorf("%v", r.Error.Message)
}
return r.Result, nil
}