Merge branch 'master' into 'master'

Make signald-go work with latest signald

See merge request signald/signald-go!1
This commit is contained in:
Finn 2020-09-12 17:23:17 +00:00
commit 0b93eb536c
3 changed files with 23 additions and 3 deletions

View file

@ -17,6 +17,7 @@ package cmd
import (
"fmt"
"log"
"os"
"github.com/spf13/cobra"
@ -50,7 +51,11 @@ func init() {
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.signald-cli.yaml)")
RootCmd.PersistentFlags().StringVarP(&socketPath, "socket", "s", "/var/run/signald/signald.sock", "the path to the signald socket file")
s = &signald.Signald{SocketPath: socketPath}
s.Connect()
err := s.Connect()
if err != nil {
log.Fatal(err)
}
}
// initConfig reads in config file and ENV variables if set.

View file

@ -19,6 +19,7 @@ import (
"log"
"github.com/spf13/cobra"
"time"
"git.callpipe.com/finn/signald-go/signald"
"git.callpipe.com/finn/signald-go/signald/client-protocol/v1"
@ -59,6 +60,20 @@ var sendCmd = &cobra.Command{
request.AttachmentFilenames = []string{attachment}
}
s.SendRequest(request)
timeout := 10
// Wait for the response
c := make(chan signald.Response)
go s.Listen(c)
select {
case <-c:
log.Println("Ok.")
case <-time.After(1 * time.Second):
// But timeout after a while
log.Fatalf("Timeout after %d seconds\n", timeout)
}
},
}

View file

@ -2,7 +2,7 @@ package v1
// JsonAddress is a signal user's contact information. a phone number, UUID or both
type JsonAddress struct {
UUID string `json:"uuid"`
UUID string `json:"uuid,omitempty"`
Number string `json:"number"`
}
@ -26,7 +26,7 @@ type JsonReadMessage struct {
type JsonSendMessageResult struct {
Address JsonAddress `json:"address"`
Success Success `json:"success"`
Success Success `json:"success"`
NetworkFailure bool `json:"networkFailure"`
UnregisteredFailure bool `json:"unregisteredFailure"`
IdentityFailure string `json:"identityFailure"`