24 Commits

Author SHA1 Message Date
Stephan Richter
ad0c231032 feat(jsonrpc2): add manual receive mode to prevent message loss
In the default 'on-start' receive mode, signal-cli's daemon
auto-pulls inbound messages and pushes them to its JSON-RPC clients
the moment they arrive from the Signal servers. If no websocket
subscriber is currently attached to /v1/receive/{number} — for
example during a brief subscriber redeploy — the receiver loop in
signal-cli-rest-api drops the message via a non-blocking channel
send (see the 'no receiver' debug log in ReceiveData). signal-cli
has already acknowledged the message to Signal, so it is never
redelivered.

Add support for signal-cli's --receive-mode=manual, opt-in via the
new JSON_RPC_RECEIVE_MODE=manual environment variable. In manual
mode signal-cli does NOT auto-receive; signal-cli-rest-api now
issues subscribeReceive when a websocket subscriber attaches and
unsubscribeReceive when the last subscriber detaches. While no
subscriber is attached, signal-cli does not pull messages from the
Signal servers, so they remain buffered server-side under Signal's
normal retention rules and are delivered to the next subscriber
that attaches.

Implementation:

* jsonrpc2-helper.go: thread JSON_RPC_RECEIVE_MODE through to the
  daemon launch command line.
* jsonrpc2.go: add per-account subscription tracking with
  refcounting; subscribeReceive/unsubscribeReceive helpers; an
  unwrap step in ReceiveData so manual-mode notifications
  ({subscription,result}) and auto-mode notifications (envelope
  directly) reach downstream consumers in the same shape.
* client.go, api.go: thread the account number through
  GetReceiveChannel so the JsonRpc2Client can attach the right
  subscription.

The change is fully backward compatible: when JSON_RPC_RECEIVE_MODE
is unset or set to 'on-start', signal-cli runs in auto mode and the
new subscribeReceive code path is bypassed (account is empty, no
RPC issued).

Closes #255 (the same root cause: no subscriber → 'no receiver'
drop).
2026-04-08 16:16:55 -04:00
Bernhard B
5c6fd14944 improved error handling in jsonrpc2-helper 2026-03-22 22:18:16 +01:00
Bernhard B
f142e8089c added new json-rpc-native mode 2026-03-21 19:49:26 +01:00
Brian (bex) Exelbierd
2760fe0b70 add --ignore-avatars and --ignore-stickers support
Expose the new signal-cli v0.14.0 --ignore-avatars and --ignore-stickers
flags across all modes:

* JSON-RPC mode: JSON_RPC_IGNORE_AVATARS and JSON_RPC_IGNORE_STICKERS
  environment variables
* Normal/Native mode: ignore_avatars and ignore_stickers query parameters
  on the /v1/receive endpoint
* Auto-receive scheduler: AUTO_RECEIVE_SCHEDULE_IGNORE_AVATARS and
  AUTO_RECEIVE_SCHEDULE_IGNORE_STICKERS environment variables

Follows the existing pattern of --ignore-attachments and --ignore-stories.

Refs #776, #723

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 22:52:26 +01:00
Bernhard B
4fb1be6657 removed fifo pathname from json-rpc config
* not needed anymore
2026-03-07 21:17:45 +01:00
Bernhard B
af18c7aea8 switched to signal-cli daemon mode
* this gets rid off the ugly netcat workaround and should improve
  the general stability of the connection to the signal-cli binary
  in json-rpc mode.
2026-03-05 20:41:17 +01:00
Bernhard B
5714161567 fixed bug in json-rpc mode
* handle 'trust-new-identities' setting in json-rpc mode

see #771
2025-12-08 22:40:03 +01:00
Bernhard B
8834570421 add env variables to ignore download of attachments and stories in json-rpc mode
see #723
2025-07-19 22:16:36 +02:00
Bernhard B
08dc98eac2 removed JAVA_HOME env variable from supervisor configuration
* not needed and is causing some problems since we switched from
  the eclipse-temurin to the ubuntu base image.

see #489
2024-02-23 10:38:36 +01:00
Bernhard B
a06a9f873b switched implementation to multi-account mode
* instead of starting signal-cli in json-rpc mode with the '-u',
  we start signal-cli without the '-u' parameter (also known as
  multi-account mode). This makes it possible to register a number in
  json-rpc mode.
2023-10-30 14:49:11 +01:00
Bernhard B
25775a4c10 implemented trust mode
* implemented possibility to set the trust mode globally

see #240
2022-05-06 19:28:23 +02:00
Bernhard B
0b6bd44838 ran go-fmt on complete sourcecode 2022-04-01 19:08:07 +02:00
Bernhard B
30341f27c7 make json-rpc mode work with linked devices
see #224
2022-03-04 20:34:11 +01:00
Bernhard B
50736ab633 fixed bug in jsonrpc2-helper
* golang doesn't automatically expand env variables in exec.Command
2022-02-25 18:41:30 +01:00
Bernhard B
6ce236a908 made UID/GID of configureable with env variables
see #216
2022-02-19 11:33:18 +01:00
Bernhard B
f8f601a498 fixed bug in json-rpc mode
* do not hardcode path to signal-cli config directory in supervisor
  config file.
2021-11-06 22:49:25 +01:00
Bernhard B
2d80ff91a2 use SIGNAL_CLI_CONFIG_DIR env variable in jsonrpc2-helper script
* do not hardcode path, but use path specified by SIGNAL_CLI_CONFIG_DIR
  env variable.
2021-11-01 10:55:07 +01:00
Bernhard B
d1190f8299 improved log message
* notify users that registering a phone number only works in
  normal/native mode.
2021-10-20 21:49:11 +02:00
Bernhard B
0023ebaf83 fixed bug in jsonrpc2-helper script
* only look for registered numbers in the signal-cli-config/data folder
  and do NOT traverse the whole signal-cli-config folder (as there might
  be other files starting with '+...'
2021-10-10 18:39:03 +02:00
Bernhard B
82fd577d48 remove any existing named pipe before creating a new one 2021-10-10 17:57:36 +02:00
Bernhard B
d7825a4da8 only add numbers to jsonrpc2.yml config file; skip any other files
starting with a '+'
2021-10-10 17:54:08 +02:00
Bernhard B
2a0347eea2 added more sanity checks + restructured code a bit 2021-09-11 23:03:01 +02:00
Bernhard B
310d07536e formatted code with gofmt 2021-09-11 22:32:31 +02:00
Bernhard B
8617aacba5 added jsonrpc2-helper script 2021-09-11 22:31:43 +02:00