Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 22396f8276 | |||
| c9a2bd80bc | |||
| 111d41b901 | |||
| 300e330b8d | |||
| d69b73c5c1 | |||
| b51c00a910 | |||
| 0fd676670f | |||
| 74992fe2c3 | |||
| 74fb4a152b | |||
| 07f5168a6a | |||
| 0631dc60a7 | |||
| 71d1800637 | |||
| c852393504 | |||
| ef7a20a94b | |||
| 21b141b7a1 | |||
| 8cef252023 | |||
| dd6726911e | |||
| 0316bc6db1 | |||
| a22970a284 | |||
| ad3edadc79 | |||
| 5a7a6d7538 | |||
| 4e55ebaf05 | |||
| 6c11327289 | |||
| f6d26e1905 | |||
| 0feb664405 | |||
| ca2a1fdf25 | |||
| c031c36a00 | |||
| 5f211c7a90 | |||
| 3bcca84908 | |||
| 93daa56db1 | |||
| c272c05092 | |||
| 67ffd89a00 | |||
| 97adac7fa4 | |||
| e24450a0af | |||
| 5bcd11703a | |||
| c4f06fa79b | |||
| b50d3bcfa2 | |||
| b55e4b8315 | |||
| 450f2c1558 | |||
| 219ef492f5 | |||
| 26e487659c | |||
| 3faadfd076 | |||
| d791203856 | |||
| 285567309a | |||
| 4e2656445c | |||
| 0cfaa93505 | |||
| 6d85c97e05 |
@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"samhofi.us/x/keybase/v2/types/chat1"
|
"samhofi.us/x/keybase/v2/types/chat1"
|
||||||
@ -44,7 +45,7 @@ func getNewMessages(k *Keybase, subs *subscriptionChannels, execOptions []string
|
|||||||
|
|
||||||
cmd = append(cmd, execString...)
|
cmd = append(cmd, execString...)
|
||||||
|
|
||||||
execCmd := execCommand(k.ExePath, cmd...)
|
execCmd := exec.Command(k.ExePath, cmd...)
|
||||||
stdOut, _ := execCmd.StdoutPipe()
|
stdOut, _ := execCmd.StdoutPipe()
|
||||||
execCmd.Start()
|
execCmd.Start()
|
||||||
scanner := bufio.NewScanner(stdOut)
|
scanner := bufio.NewScanner(stdOut)
|
||||||
@ -753,35 +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 result `json:"result"`
|
Result []chat1.ConvSummary `json:"result"`
|
||||||
Error *Error `json:"error,omitempty"`
|
Error *Error `json:"error,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var r res
|
var r res
|
||||||
|
|
||||||
arg := newListConvsOnNameArg(channel)
|
opts := SendMessageOptions{
|
||||||
|
Channel: channel,
|
||||||
|
}
|
||||||
|
|
||||||
|
arg := newSendMessageArg(opts)
|
||||||
|
arg.Method = "listconvsonname"
|
||||||
|
|
||||||
jsonBytes, _ := json.Marshal(arg)
|
jsonBytes, _ := json.Marshal(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 nil, err
|
return r.Result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(cmdOut, &r)
|
err = json.Unmarshal(cmdOut, &r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return r.Result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Error != nil {
|
if r.Error != nil {
|
||||||
return nil, fmt.Errorf("%v", r.Error.Message)
|
return r.Result, fmt.Errorf("%v", r.Error.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &r.Result.Conversations, nil
|
return r.Result, nil
|
||||||
}
|
}
|
||||||
2
go.mod
2
go.mod
@ -1,3 +1,3 @@
|
|||||||
module samhofi.us/x/keybase
|
module samhofi.us/x/keybase/v2
|
||||||
|
|
||||||
go 1.13
|
go 1.13
|
||||||
|
|||||||
@ -9,9 +9,6 @@ import (
|
|||||||
"samhofi.us/x/keybase/v2/types/chat1"
|
"samhofi.us/x/keybase/v2/types/chat1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Used for testing
|
|
||||||
var execCommand = exec.Command
|
|
||||||
|
|
||||||
// Possible MemberTypes
|
// Possible MemberTypes
|
||||||
const (
|
const (
|
||||||
TEAM string = "team"
|
TEAM string = "team"
|
||||||
@ -73,7 +70,7 @@ func (k *Keybase) Exec(command ...string) ([]byte, error) {
|
|||||||
|
|
||||||
cmd = append(cmd, command...)
|
cmd = append(cmd, command...)
|
||||||
|
|
||||||
out, err := execCommand(k.ExePath, cmd...).Output()
|
out, err := exec.Command(k.ExePath, cmd...).Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []byte{}, err
|
return []byte{}, err
|
||||||
}
|
}
|
||||||
@ -114,7 +114,6 @@ type SendMessageOptions struct {
|
|||||||
ReplyTo *chat1.MessageID `json:"reply_to,omitempty"`
|
ReplyTo *chat1.MessageID `json:"reply_to,omitempty"`
|
||||||
ExplodingLifetime *ExplodingLifetime `json:"exploding_lifetime,omitempty"`
|
ExplodingLifetime *ExplodingLifetime `json:"exploding_lifetime,omitempty"`
|
||||||
UnreadOnly bool `json:"unread_only,omitempty"`
|
UnreadOnly bool `json:"unread_only,omitempty"`
|
||||||
NonBlock bool `json:"nonblock,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type sendMessageParams struct {
|
type sendMessageParams struct {
|
||||||
@ -239,24 +238,6 @@ 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"`
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user