fix(chat,channels): admin session delete, weixin inbound, PG and docs

- List/delete chat sessions for administrator by username (cross-tenant UUID)

- Return 404 when delete does not remove a session; add tests

- Weixin: dispatch lang, inbound attachments, reply persist, native reply timeout

- PG compat scrub and administrator session delete repo path

- RUNBOOK: WhatsApp re-bind with Remove-Item auth; weixin poll diag scripts

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-06-03 01:36:45 +08:00
parent 39fd1905b6
commit bc1b45a8fd
20 changed files with 1056 additions and 86 deletions

View file

@ -1384,6 +1384,32 @@ class SqliteStore:
tenant_id=tenant_id, user_id=user_id
)
def list_sessions_for_administrator_username(
self,
*,
username: str,
limit: int | None = None,
offset: int = 0,
) -> list[ChatSession]:
return self._chat_sessions_repo().list_chat_sessions_for_administrator_username(
username=username,
limit=limit,
offset=int(offset),
)
def get_sessions_list_meta_for_administrator_username(self, *, username: str) -> SessionsListMeta:
return self._chat_sessions_repo().sessions_list_meta_for_administrator_username(
username=username
)
def get_session_for_administrator_username(
self, *, session_id: str, username: str
) -> Optional[ChatSession]:
return self._chat_sessions_repo().fetch_chat_session_for_administrator_username(
session_id=session_id,
username=username,
)
def list_sessions_for_tenant(
self,
*,
@ -1813,11 +1839,19 @@ class SqliteStore:
return int(total_row_c or 0), users, totals
def delete_session_in_tenant(self, *, session_id: str, tenant_id: str) -> bool:
"""Delete session if it belongs to tenant (used by administrator account)."""
"""Delete session if it belongs to tenant."""
return self._chat_sessions_repo().try_delete_chat_session_for_tenant(
session_id=session_id, tenant_id=tenant_id
)
def delete_session_for_administrator_username(
self, *, session_id: str, username: str
) -> bool:
"""Delete session owned by any ``app_user`` row with this login name (cross-tenant)."""
return self._chat_sessions_repo().try_delete_chat_session_for_administrator_username(
session_id=session_id, username=username
)
def delete_session(self, session_id: str) -> None:
self._chat_sessions_repo().delete_chat_session_by_id(session_id=session_id)