fix(messenger): auto-whitelist a recipient after an outbound 1:1 send - #125
Conversation
E-mail already treats sending to an address as proof the correspondent is wanted (the Sent-folder-derived whitelist), so their reply is a known sender. The messenger channels had no equivalent: a reply from someone the user had just messaged arrived as an 'unknown sender' and prompted the user to whitelist a contact they were already actively conversing with. Add the missing analogue: - triage_policy.auto_whitelist_on_send(channel, handles): idempotent, write-if-changed, and never re-whitelists a currently-blacklisted handle (an explicit block must survive an outbound send). - whatsapp-gateway._autowhitelist_recipient(): called from the _push send choke point (covering both the direct and approved-pending send paths). Skips group/broadcast recipients; whitelists the recipient as addressed so it matches the bare-user key inbound is gated on, plus its LID<->PN counterpart when the bridge's LID store knows it (_lid_to_pn / _pn_to_lid), so a later inbound under either identity is recognised. Best-effort: it can never break a send. Signal and Telegram share the same gap and can reuse the shared helper; wiring them needs per-channel recipient<->inbound-handle care (UUID vs number, username vs id) and is left as a follow-up. Co-Authored-By: Claude <noreply@anthropic.com>
|
Reviewed the diff against the branch (both files, plus the call graph in
One gap: the PR description says "Unit-tested No functional issues found otherwise — nothing here should block the merge. |
Problem
E-mail already treats sending to an address as proof the correspondent is wanted — the whitelist is derived from the Sent folder — so their reply lands as a known sender. The messenger channels (WhatsApp/Signal/Telegram) had no equivalent: sending someone a message did nothing to the inbound whitelist, so their reply arrived as an "unknown sender" and the user was prompted to whitelist a contact they were already actively conversing with.
Observed in the wild: the user sent a WhatsApp message to a contact; the contact's reply opened a fresh "unknown sender — whitelist?" thread instead of being recognised.
Fix
triage_policy.auto_whitelist_on_send(channel, handles)— the messenger analogue of the Sent-folder auto-whitelist. Idempotent and write-if-changed (an already-known handle is a no-op → no qlever rebuild churn). Never re-whitelists a currently-blacklisted handle — an explicit block must survive an outbound send. Returns the handles newly added.whatsapp-gateway._autowhitelist_recipient(recipient)— called from the_pushsend choke point, which covers both the direct (allow/--user-approved) path and the approved-pending (verify) path. It:_jid_user), so a reply to the inbound's exact origin (LID or PN) matches;_lid_to_pn/_pn_to_lid), so a later inbound under either identity is recognised;Scope / follow-up
Signal and Telegram share the same gap and can reuse the shared helper. Wiring them needs per-channel recipient↔inbound-handle care (Signal number vs UUID; Telegram username vs numeric id), so it's left as a follow-up rather than guessed at here.
Testing
Unit-tested
auto_whitelist_on_send: fresh add, idempotent re-add, blacklist protection, empty/junk input, and gate integration (a whitelisted sender forwards withflagged_unknown=False). Both files passast.parse.