Skip to content

Instantly share code, notes, and snippets.

@kverb
Created January 20, 2021 18:51
Show Gist options
  • Save kverb/8541f95287dcd886f638406af36257b3 to your computer and use it in GitHub Desktop.
Save kverb/8541f95287dcd886f638406af36257b3 to your computer and use it in GitHub Desktop.
fixup SignalGroup struct & signal-cli daemon cmd for 0.7.4
commit 132eb3276585e8d33801e109094cbd00ca59a8d9
Author: kverb <ken@kverb.com>
Date: Wed Jan 20 10:38:40 2021 -0800
fixup SignalGroup struct & signal-cli daemon cmd for 0.7.4
As of signal-cli v.0.7.4, the exec command needs to be slightly changed
in order to scan stdout correctly.
This might just be an issue with a warning message being emitted in
signal-cli's output. Perhaps the `processWire` command just needs a
more robust handling of stdout lines.
The signalGroup struct appears to fix a crash with serializing from JSON
----
tested by nuking .local data & re-linking device with signal-cli v.0.7.4
`make build && bin/siggo -d`
before patch, siggo loads by chat history is empty
after patch, siggo loads contacts and groups.
tested sending message to a contact as well.
diff --git a/signal/signal.go b/signal/signal.go
index 96f5546..443e11f 100644
--- a/signal/signal.go
+++ b/signal/signal.go
@@ -55,6 +55,7 @@ type SignalContact struct {
Blocked bool `json:"blocked"`
InboxPosition *int `json:"inboxPosition"`
Archived bool `json:"archived"`
+ UUID string `json:uuid"`
}
// SignalGroup is the data that signal-cli saves for each group
@@ -62,12 +63,13 @@ type SignalContact struct {
type SignalGroup struct {
GroupID string `json:"groupId"`
Name string `json:"name"`
- Members []*SignalGroupMember `json:"members"`
+ Members []*string `json:"members"`
Color string `json:"color"`
Blocked bool `json:"blocked"`
InboxPosition *int `json:"inboxPosition"`
Archived bool `json:"archived"`
MessageExpirationTime int `json:"messageExpirationTime"`
+ ExpectedV2Id string `json:"expectedV2Id"`
}
// SignalGroupMember is a member of a signal group
@@ -202,7 +204,7 @@ func (s *Signal) ReceiveForever() {
// Daemon starts the dbus daemon and receives forever.
func (s *Signal) Daemon() error {
- cmd := exec.Command("signal-cli", "-u", s.uname, "daemon", "--json")
+ cmd := exec.Command("signal-cli", "--output=json", "-u", s.uname, "daemon")
// This is the only way to ensure that the signal-cli daemon is killed when we get
// SIGKILL, but it isn't available on MacOS, so we leave it commented out for now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment