Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a8e68baf4 | |||
| acc3e3ddec |
25
chat.go
25
chat.go
@ -754,36 +754,35 @@ func (k *Keybase) ListMembersOfConversation(convID chat1.ConvIDStr) (chat1.ChatM
|
||||
}
|
||||
|
||||
// ListConvsOnName returns a list of all conversations for a chat1.ChatChannel
|
||||
func (k *Keybase) ListConvsOnName(channel chat1.ChatChannel) ([]chat1.ConvSummary, error) {
|
||||
func (k *Keybase) ListConvsOnName(channel chat1.ChatChannel) (*[]chat1.ConvSummary, error) {
|
||||
type result struct {
|
||||
Conversations []chat1.ConvSummary `json:"conversations"`
|
||||
}
|
||||
|
||||
type res struct {
|
||||
Result []chat1.ConvSummary `json:"result"`
|
||||
Error *Error `json:"error,omitempty"`
|
||||
Result result `json:"result"`
|
||||
Error *Error `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
var r res
|
||||
|
||||
opts := SendMessageOptions{
|
||||
Channel: channel,
|
||||
}
|
||||
|
||||
arg := newSendMessageArg(opts)
|
||||
arg.Method = "listconvsonname"
|
||||
arg := newListConvsOnNameArg(channel)
|
||||
|
||||
jsonBytes, _ := json.Marshal(arg)
|
||||
|
||||
cmdOut, err := k.Exec("chat", "api", "-m", string(jsonBytes))
|
||||
if err != nil {
|
||||
return r.Result, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(cmdOut, &r)
|
||||
if err != nil {
|
||||
return r.Result, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if r.Error != nil {
|
||||
return r.Result, fmt.Errorf("%v", r.Error.Message)
|
||||
return nil, fmt.Errorf("%v", r.Error.Message)
|
||||
}
|
||||
|
||||
return r.Result, nil
|
||||
return &r.Result.Conversations, nil
|
||||
}
|
||||
|
||||
18
types.go
18
types.go
@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user