fix: align with observed signal-cli-rest-api behaviour
Real-frame parsing test, README notes from live verification (manual mode needs a build newer than 0.101, sync before listing groups, 30-day phone rule, observed errors and long texts), compose image pinned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
136e431917
commit
788dd0b968
3 files changed
+41
-4
No files matched your search
@@ -67,7 +67,10 @@ Errors can be checked with `errors.Is`: `ErrNotLinked`,
|
||||
`ErrRateLimited` (429), `ErrEmptyText`, `ErrNotJSONRPC` (the service is not in
|
||||
`MODE=json-rpc`/`json-rpc-native`; `Listen` stops instead of silently
|
||||
consuming messages). Other API errors are `*APIError`
|
||||
(`StatusCode`, `Message`). `Send` never retries.
|
||||
(`StatusCode`, `Message`). `Send` never retries. Observed: an unknown
|
||||
group gives `400 Invalid identifier group.…`, an invalid number
|
||||
`400 Failed to send message`. Long texts work: a 3,000-character message
|
||||
arrives whole, shown truncated with a "Read more" link in the Signal app.
|
||||
|
||||
See [`examples/`](examples/) for a complete app and a docker-compose file.
|
||||
|
||||
@@ -84,7 +87,10 @@ See [`examples/`](examples/) for a complete app and a docker-compose file.
|
||||
you can also open
|
||||
`http://localhost:8080/v1/qrcodelink?device_name=signalbot` in a browser
|
||||
and scan the PNG.
|
||||
4. **Find the group id**: `signalbot groups` (it warns if the bot is not an
|
||||
4. **Sync once, then find the group id.** With `JSON_RPC_RECEIVE_MODE=manual`,
|
||||
signal-cli fetches nothing (not even the group list) until something
|
||||
listens: run `signalbot listen` for a few seconds first. Then
|
||||
`signalbot groups` (it warns if the bot is not an
|
||||
admin or the group is not admins-only). Test with
|
||||
`signalbot send -to group.… "hello"` and `signalbot listen`.
|
||||
5. **Unpublish the port** and configure your app with the service URL and
|
||||
@@ -98,7 +104,15 @@ See [`examples/`](examples/) for a complete app and a docker-compose file.
|
||||
- **Use `JSON_RPC_RECEIVE_MODE=manual`.** With the default (`on-start`),
|
||||
messages that arrive while your app is down are silently lost. With
|
||||
`manual`, they stay queued by Signal and are delivered when `Listen`
|
||||
reconnects.
|
||||
reconnects (verified). This setting is newer than the 0.101 release
|
||||
(2026-09-25): use a later build. signalbot was verified with
|
||||
`bbernhard/signal-cli-rest-api:1794354199-ci` (master build of
|
||||
2026-11-10); switch to the next stable tag when it is out.
|
||||
- **Open Signal on the bot's phone at least once every 30 days**, or
|
||||
Signal unlinks its linked devices, including the bot
|
||||
([Signal support](https://support.signal.org/hc/en-us/articles/360007320551)).
|
||||
A linked device is also unlinked after 45 days of inactivity, which a
|
||||
permanently running `Listen` avoids.
|
||||
- **Never expose the service publicly**: signal-cli-rest-api has no
|
||||
authentication. Keep it on the compose network.
|
||||
- **Keep the volume.** It holds the account keys; losing it means linking
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Minimal deployment: the Signal service and an app using signalbot.
|
||||
services:
|
||||
signal-api:
|
||||
image: bbernhard/signal-cli-rest-api:0.101
|
||||
image: bbernhard/signal-cli-rest-api:1794354199-ci # needs a build newer than 0.101 for JSON_RPC_RECEIVE_MODE
|
||||
environment:
|
||||
- MODE=json-rpc-native # fallback: MODE=json-rpc if native mode is unstable
|
||||
- JSON_RPC_RECEIVE_MODE=manual # keep messages queued while the app is down
|
||||
|
||||
@@ -101,3 +101,26 @@ func TestReplyTargets(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Real frames captured from signal-cli-rest-api (build 1794354199-ci,
|
||||
// MODE=json-rpc-native, JSON_RPC_RECEIVE_MODE=manual), anonymised.
|
||||
const (
|
||||
realDirect = `{"envelope":{"source":"+33600000001","sourceNumber":"+33600000001","sourceUuid":"b26a99ac-0000-4c6a-84da-000000000001","sourceName":"Alice","sourceDevice":1,"timestamp":1795187556780,"serverReceivedTimestamp":1795187558661,"serverDeliveredTimestamp":1795187610311,"dataMessage":{"timestamp":1795187556780,"message":"sbtest direct","expiresInSeconds":0,"isExpirationUpdate":false,"viewOnce":false,"isEndSession":false,"isProfileKeyUpdate":false,"hasProfileKey":true}},"account":"+33600000000"}`
|
||||
realGroup = `{"envelope":{"source":"+33600000001","sourceNumber":"+33600000001","sourceUuid":"b26a99ac-0000-4c6a-84da-000000000001","sourceName":"Alice","sourceDevice":1,"timestamp":1795187575919,"serverReceivedTimestamp":1795187577893,"serverDeliveredTimestamp":1795187610312,"dataMessage":{"timestamp":1795187575919,"message":"sbtest groupe 🎬 accentué","expiresInSeconds":0,"isExpirationUpdate":false,"viewOnce":false,"isEndSession":false,"isProfileKeyUpdate":false,"hasProfileKey":true,"groupInfo":{"groupId":"aXdGf/8kFRszxYAbAvV238fSrZ115FoB62/5/fYgtmo=","groupName":"Test","revision":2,"type":"DELIVER"}}},"account":"+33600000000"}`
|
||||
realReaction = `{"envelope":{"source":"+33600000001","sourceNumber":"+33600000001","sourceUuid":"b26a99ac-0000-4c6a-84da-000000000001","sourceName":"Alice","sourceDevice":1,"timestamp":1795187612623,"dataMessage":{"timestamp":1795187612623,"message":null,"expiresInSeconds":0,"viewOnce":false,"hasProfileKey":false,"reaction":{"emoji":"👍🏻","targetAuthor":"+33600000001","targetSentTimestamp":1795187575919,"isRemove":false},"groupInfo":{"groupId":"aXdGf/8kFRszxYAbAvV238fSrZ115FoB62/5/fYgtmo=","groupName":"Test","revision":2,"type":"DELIVER"}}},"account":"+33600000000"}`
|
||||
)
|
||||
|
||||
func TestParseRealFrames(t *testing.T) {
|
||||
d, ok := parseEnvelope([]byte(realDirect), self)
|
||||
if !ok || d.From != "+33600000001" || d.GroupID != "" || d.Text != "sbtest direct" {
|
||||
t.Fatalf("direct: %+v, %v", d, ok)
|
||||
}
|
||||
g, ok := parseEnvelope([]byte(realGroup), self)
|
||||
// Same id as GET /v1/groups returned for this group.
|
||||
if !ok || g.GroupID != "group.YVhkR2YvOGtGUnN6eFlBYkF2VjIzOGZTcloxMTVGb0I2Mi81L2ZZZ3Rtbz0=" || g.Text != "sbtest groupe 🎬 accentué" {
|
||||
t.Fatalf("group: %+v, %v", g, ok)
|
||||
}
|
||||
if _, ok := parseEnvelope([]byte(realReaction), self); ok {
|
||||
t.Fatal("reaction accepted")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user