Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| acc3e3ddec |
26
chat.go
26
chat.go
@ -754,36 +754,36 @@ func (k *Keybase) ListMembersOfConversation(convID chat1.ConvIDStr) (chat1.ChatM
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListConvsOnName returns a list of all conversations for a chat1.ChatChannel
|
// 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 {
|
type res struct {
|
||||||
Result []chat1.ConvSummary `json:"result"`
|
Result result `json:"result"`
|
||||||
Error *Error `json:"error,omitempty"`
|
Error *Error `json:"error,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var r res
|
var r res
|
||||||
|
|
||||||
opts := SendMessageOptions{
|
arg := newListConvsOnNameArg(channel)
|
||||||
Channel: channel,
|
|
||||||
}
|
|
||||||
|
|
||||||
arg := newSendMessageArg(opts)
|
|
||||||
arg.Method = "listconvsonname"
|
|
||||||
|
|
||||||
jsonBytes, _ := json.Marshal(arg)
|
jsonBytes, _ := json.Marshal(arg)
|
||||||
|
fmt.Printf("%#v\n", arg)
|
||||||
|
|
||||||
cmdOut, err := k.Exec("chat", "api", "-m", string(jsonBytes))
|
cmdOut, err := k.Exec("chat", "api", "-m", string(jsonBytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.Result, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(cmdOut, &r)
|
err = json.Unmarshal(cmdOut, &r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.Result, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Error != nil {
|
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
|
// KVOptions holds a set of options to be passed to the KV methods
|
||||||
type KVOptions struct {
|
type KVOptions struct {
|
||||||
Team *string `json:"team"`
|
Team *string `json:"team"`
|
||||||
|
|||||||
Reference in New Issue
Block a user