Merge branch 'master' into 'master'
Make signald-go work with latest signald See merge request signald/signald-go!1
This commit is contained in:
commit
0b93eb536c
3 changed files with 23 additions and 3 deletions
|
@ -17,6 +17,7 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"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().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")
|
RootCmd.PersistentFlags().StringVarP(&socketPath, "socket", "s", "/var/run/signald/signald.sock", "the path to the signald socket file")
|
||||||
s = &signald.Signald{SocketPath: socketPath}
|
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.
|
// initConfig reads in config file and ENV variables if set.
|
||||||
|
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.callpipe.com/finn/signald-go/signald"
|
"git.callpipe.com/finn/signald-go/signald"
|
||||||
"git.callpipe.com/finn/signald-go/signald/client-protocol/v1"
|
"git.callpipe.com/finn/signald-go/signald/client-protocol/v1"
|
||||||
|
@ -59,6 +60,20 @@ var sendCmd = &cobra.Command{
|
||||||
request.AttachmentFilenames = []string{attachment}
|
request.AttachmentFilenames = []string{attachment}
|
||||||
}
|
}
|
||||||
s.SendRequest(request)
|
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)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package v1
|
||||||
|
|
||||||
// JsonAddress is a signal user's contact information. a phone number, UUID or both
|
// JsonAddress is a signal user's contact information. a phone number, UUID or both
|
||||||
type JsonAddress struct {
|
type JsonAddress struct {
|
||||||
UUID string `json:"uuid"`
|
UUID string `json:"uuid,omitempty"`
|
||||||
Number string `json:"number"`
|
Number string `json:"number"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ type JsonReadMessage struct {
|
||||||
|
|
||||||
type JsonSendMessageResult struct {
|
type JsonSendMessageResult struct {
|
||||||
Address JsonAddress `json:"address"`
|
Address JsonAddress `json:"address"`
|
||||||
Success Success `json:"success"`
|
Success Success `json:"success"`
|
||||||
NetworkFailure bool `json:"networkFailure"`
|
NetworkFailure bool `json:"networkFailure"`
|
||||||
UnregisteredFailure bool `json:"unregisteredFailure"`
|
UnregisteredFailure bool `json:"unregisteredFailure"`
|
||||||
IdentityFailure string `json:"identityFailure"`
|
IdentityFailure string `json:"identityFailure"`
|
||||||
|
|
Loading…
Reference in a new issue