Productize scheduled success delivery, close WA pending, and clarify SQL scope grants.

Wrap successful scheduled jobs with a short WA header (+ attachment count), expire stale access pending and DM requesters on admin approve/deny, and add concrete next_steps for insufficient_scope:sql:query.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-10 23:52:41 +08:00
parent dff8901ae3
commit 4898adf7d0
10 changed files with 334 additions and 12 deletions

View file

@ -1052,8 +1052,12 @@ def process_inbound_payload(payload: dict[str, Any]) -> dict[str, Any]:
)
channel_is_wa_bind = str(inbound.channel or "").strip().lower() == "whatsapp"
if info:
guide = _menu_text(channel=str(inbound.channel or ""))
reply = ("Bound successfully.\n\n" + guide) if channel_is_wa_bind else ("绑定成功。\n\n" + guide)
if channel_is_wa_bind:
from runtime.extensions.whatsapp.access_control import access_granted_guide_text
reply = access_granted_guide_text(lang="en")
else:
reply = "绑定成功。\n\n" + _menu_text(channel=str(inbound.channel or ""))
else:
reply = (
"Bind failed: invalid or already used code."

View file

@ -264,6 +264,30 @@ def _notify_requester_access_decision(
)
def notify_whatsapp_access_decision(
store: Any,
*,
tenant_id: str,
account_id: str,
lang: str = "en",
external_user_id: str,
phone: str = "",
pending_id: str = "",
approved: bool,
) -> None:
"""Public wrapper for admin/API approve paths to DM the requester."""
_notify_requester_access_decision(
store,
tenant_id=tenant_id,
account_id=account_id,
lang=lang,
external_user_id=external_user_id,
phone=phone,
pending_id=pending_id,
approved=approved,
)
def _upsert_whatsapp_contact_profile(
store: Any,
*,