feat(чат): категории жалоб и attention

This commit is contained in:
anor
2026-11-06 22:45:33 +10:00
parent 45102c3dde
commit 4f3d47926a
6 changed files with 100 additions and 11 deletions
+6 -1
View File
@@ -2034,9 +2034,14 @@ async def feedback(request: Request):
comment = (body.get("comment") or "").strip()[:2000]
answer = (body.get("answer") or "")[:8000]
tab_id = _get_tab(request, body)
category = (body.get("category") or "").strip()[:40] or None
source = (body.get("source") or "chat").strip()[:40] or "chat"
allowed = {"wrong_answer", "off_topic", "failure", "praise"}
if category is not None and category not in allowed:
raise HTTPException(400, "unknown category")
if not comment and not answer:
raise HTTPException(400, "Empty feedback")
await asyncio.to_thread(save_feedback, user, tab_id, comment, answer)
await asyncio.to_thread(save_feedback, user, tab_id, comment, answer, category, source)
ip = _client_ip(request) or None
log_action(user, "feedback", "POST", "/api/feedback", comment[:120], ip, 200)
# Жалоба — самый дорогой сигнал: человек не ушёл молча, а потратил силы. Раньше