fix: enable UseRetryMessageStore so retry-receipts are handled

Symptom
-------
Recipients whose Signal session hasn't been freshly bootstrapped — most
commonly the sender's own other linked devices (e.g. WhatsApp Desktop
linked to the same account, or other linked devices of the recipient)
— receive messages sent by wacli but cannot decrypt them, and see
"Waiting for this message" indefinitely in WhatsApp.

Cause
-----
When a recipient device fails to decrypt, it sends a retry-receipt.
whatsmeow's retry handler looks up the original plaintext to re-encrypt
it with fresh session state. The lookup path is:

    in-memory recentMessages cache
      → GetMessageForRetry() callback (unset in wacli)
      → retry_message_store DB table (only if UseRetryMessageStore=true)

The `wacli send …` subcommand sends the message, then exits — the
in-memory cache dies with the process. `wacli sync` is a separate
process that never saw the outgoing message, so its in-memory cache
is empty too. Neither can answer the retry receipt, and whatsmeow
logs:

    Failed to handle retry receipt for <jid>/<id> from <jid>:<n>: couldn't find message <id>

Fix
---
Setting `c.client.UseRetryMessageStore = true` tells whatsmeow to
persist outgoing messages to its `retry_message_store` SQLite table
during Send(). A later wacli process (e.g. `wacli sync` restarting
after a `wacli send …` subcommand) then finds the plaintext via the
shared store, re-encrypts, and the recipient's "Waiting for this
message" resolves to the real content.

Reproduction
------------
1. Authenticate wacli via `wacli auth` (linked device pairing)
2. Send: `wacli send text --to <your own number> --message "hi"` so
   the target account has multiple linked devices
3. Observe: at least one recipient device shows "Waiting for this
   message. Check your phone." with the "retry receipt" log line
   above in the sender's journal.
4. With this patch applied: message is decrypted correctly on every
   recipient device, including ones that weren't online at send time.

Scope
-----
Six-line change. No new dependencies. whatsmeow handles the DB schema
(creates the `retry_message_store` table on first use); no migration
needed on existing installs.
This commit is contained in:
SimDamDev 2026-04-19 00:44:51 +02:00 committed by Peter Steinberger
parent eb562ce875
commit 70f2afd470

View File

@ -62,6 +62,12 @@ func (c *Client) init() error {
logger := waLog.Stdout("Client", "ERROR", true)
c.client = whatsmeow.NewClient(deviceStore, logger)
// Persist recently-sent messages so whatsmeow can answer retry-receipts
// across process restarts. Without this, recipients whose Signal session
// has not been freshly bootstrapped (typically other linked devices)
// see "Waiting for this message" indefinitely because whatsmeow can't
// find the original plaintext to re-encrypt when the retry arrives.
c.client.UseRetryMessageStore = true
return nil
}