feat(whatsapp): real group @mentions and cleaner inbound text

Wire mention JIDs/names through scheduled delivery and immediate replies (including attachment captions), sanitize group message text for the model, and surface channel-derived sessions in admin Chat.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-07-13 20:05:43 +08:00
parent cbe68a54cd
commit ad5d1db3c6
19 changed files with 1507 additions and 58 deletions

View file

@ -386,9 +386,10 @@ def _resolve_chat_session(store: SqliteStore, ctx: dict[str, Any], session_id: s
user_id = str(ctx.get("user_id") or "")
sid = str(session_id or "").strip()
if _is_administrator_chat_viewer(ctx):
sess = store.get_session_for_administrator_username(
sess = store.get_session_for_administrator_chat_view(
session_id=sid,
username=_chat_username(ctx),
tenant_id=tenant_id,
)
if sess is not None:
return sess
@ -891,9 +892,11 @@ def include_chat_routes(router: APIRouter, *, resolve_auth: Callable[[SqliteStor
user_id = str(ctx.get("user_id") or "")
if _is_administrator_chat_viewer(ctx):
uname = _chat_username(ctx)
meta = store.get_sessions_list_meta_for_administrator_username(username=uname)
rows = store.list_sessions_for_administrator_username(
username=uname, limit=limit, offset=offset
meta = store.get_sessions_list_meta_for_administrator_chat_view(
username=uname, tenant_id=tenant_id
)
rows = store.list_sessions_for_administrator_chat_view(
username=uname, tenant_id=tenant_id, limit=limit, offset=offset
)
else:
meta = store.get_sessions_list_meta_for_user(tenant_id=tenant_id, user_id=user_id)