Fix duplicate WhatsApp outbound delivery.

Claim pending rows atomically and serialize the sidecar poller so overlapping polls cannot send the same reply twice; also stop inbound queue delivery from falling through to a second enqueue.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-07-22 11:41:52 +08:00
parent 10ae4abc1d
commit b6e023cd91
6 changed files with 193 additions and 14 deletions

View file

@ -294,7 +294,11 @@ def create_app() -> FastAPI:
store = get_assistant_store()
aid = str(account_id or os.getenv("AIA_WHATSAPP_ACCOUNT_ID") or "wa-default").strip()
items = store.list_pending_channel_outbound_messages(channel="whatsapp", account_id=aid, limit=limit)
claimer = getattr(store, "claim_pending_channel_outbound_messages", None)
if callable(claimer):
items = claimer(channel="whatsapp", account_id=aid, limit=limit)
else:
items = store.list_pending_channel_outbound_messages(channel="whatsapp", account_id=aid, limit=limit)
return {"ok": True, "items": items}
@app.post("/whatsapp/outbound/ack")