fix: admin видит чужие сессии через /?tab=UUID
get_history() ищет по username+tab_id. Если пусто и role=admin, fallback на get_history_any_user(tab_id) — без фильтра по username. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -190,6 +190,17 @@ def list_invites() -> list[dict]:
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
|
||||
def get_history_any_user(tab_id: str, limit: int = 100) -> list[dict]:
|
||||
"""Get chat history for a tab regardless of username (admin view)."""
|
||||
with _conn() as conn:
|
||||
rows = conn.execute(
|
||||
"SELECT role, content, timestamp FROM messages "
|
||||
"WHERE tab_id = ? ORDER BY id DESC LIMIT ?",
|
||||
(tab_id, limit),
|
||||
).fetchall()
|
||||
return [dict(r) for r in reversed(rows)]
|
||||
|
||||
|
||||
def list_sessions(username: str) -> list[dict]:
|
||||
"""List all chat sessions for a user with last message preview."""
|
||||
with _conn() as conn:
|
||||
|
||||
Reference in New Issue
Block a user