fix(whatsapp): make every silent disposition observable, stop pure silence for linked senders (#1563)

* fix(whatsapp): make every silent disposition observable, stop pure silence for linked senders (#1552)

Silence was a legitimate outcome in seven places and none left a trace a
support question could be answered from. Now:

- Unknown-sender declines (over quota, quota RPC failure, greeting
  throttle) persist content-free trace rows: wamid, phone hash, type,
  disposition. No body, media, raw payload, or profile name; capped at
  20 rows per hash and day; deleted by the existing 30-day retention.
  The wamid dedupe also stops redelivered bad-code/greeting messages
  from earning a second reply.
- Linked-sender deliberate silences (muted, stale tap, ignorable type)
  record their reason on the skipped row.
- Non-policy silences reply: a row missing its media reference sends
  M18 through the link's reply address, a link revoked between arrival
  and processing sends the M1 unlinked copy (greeting-throttled).
- Outbound rows keep WHY a send failed (Graph error detail), and Meta
  'failed' delivery statuses store their error code and title.
- The WhatsApp settings panel shows the last inbound event (closed
  enum, server-derived) and warns when the latest reply never left.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(whatsapp): include errorDetail in typed sendText mock results

SendTextResult gained errorDetail; vi.mocked call sites must match the
widened type or they raise fresh tsc errors over the repo baseline.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(whatsapp): review fixes: fail-closed greeting throttle, cap only declined traces

From CodeRabbit's pass on #1563:
- greetingThrottled fails closed when the throttle window cannot be
  read, matching the unknown-sender quota's stance.
- The decline-trace day cap applies only to 'skipped' rows (the one
  unbounded path); 'done' traces always insert so the wamid dedupe
  keeps preventing duplicate M1/M2 replies even past the cap. Their
  volume is already bounded upstream by the greeting throttle and the
  pre-binding quota.
- company-question test mocks match the widened SendTextResult.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-08-13 16:02:16 +02:00
committed by GitHub
co-authored by Claude Fable 5 Jakob Wennberg
parent 73c63209f1
commit 6c64dd2312
18 changed files with 573 additions and 69 deletions
+13 -1
View File
@@ -3060,7 +3060,19 @@
"revoke_note": "Your documents in Accounted are not affected.",
"revoke_confirm": "Disconnect your WhatsApp number? You can link it again at any time with a new code.",
"revoked_toast": "The number is disconnected.",
"revoke_failed": "Could not disconnect the number."
"revoke_failed": "Could not disconnect the number.",
"last_event_label": "Latest message",
"last_event_filed": "the receipt is in Underlag",
"last_event_handled": "handled",
"last_event_processing": "being processed",
"last_event_awaiting_company": "waiting for a company choice in the chat",
"last_event_duplicate": "skipped: the same file already exists",
"last_event_rate_limited": "skipped: too many files",
"last_event_unsupported": "unsupported file type",
"last_event_muted": "ignored: the chat is paused",
"last_event_declined": "not answered",
"last_event_failed": "could not be received",
"last_reply_failed": "Our latest reply could not be delivered in WhatsApp. Check that the number can receive messages from Accounted."
},
"inbox_bulk_book": {
"total_label": "Total for the documents: {amount}",
+13 -1
View File
@@ -3060,7 +3060,19 @@
"revoke_note": "Dina underlag i Accounted påverkas inte.",
"revoke_confirm": "Vill du koppla från ditt WhatsApp-nummer? Du kan koppla det igen när som helst med en ny kod.",
"revoked_toast": "Numret är frånkopplat.",
"revoke_failed": "Kunde inte koppla från numret."
"revoke_failed": "Kunde inte koppla från numret.",
"last_event_label": "Senaste meddelande",
"last_event_filed": "kvittot ligger i Underlag",
"last_event_handled": "hanterat",
"last_event_processing": "behandlas",
"last_event_awaiting_company": "väntar på företagsval i chatten",
"last_event_duplicate": "hoppades över: samma fil finns redan",
"last_event_rate_limited": "hoppades över: för många filer",
"last_event_unsupported": "filtypen stöds inte",
"last_event_muted": "ignorerades: chatten är pausad",
"last_event_declined": "besvarades inte",
"last_event_failed": "kunde inte tas emot",
"last_reply_failed": "Vårt senaste svar kunde inte levereras i WhatsApp. Kontrollera att numret kan ta emot meddelanden från Accounted."
},
"inbox_bulk_book": {
"total_label": "Underlagens summa: {amount}",