🌊 Волна 10: backend client-controlled + лимиты (5 багов)
- client_controlled_hints_game: hints_used из user_progress (game.py + database.py) - client_controlled_hints_bubblewords: current_hints_used из bubble_words_progress (bubblewords.py + database.py) - client_controlled_mistakes_wordquiz: current_mistakes из word_quiz_progress (wordquiz.py + database.py) - sentence_hint_no_limit: таблица sentence_hints_used + лимит 1 раз (sentences.py + database.py) - typing_hint_no_limit: таблица typing_hints_used + лимит 1 раз (typing.py + database.py) Аудит v2: Issue #5, backend 5/10 задач
This commit is contained in:
+17
-2
@@ -98,8 +98,8 @@ async def check_typing_sentence(request: Request):
|
||||
|
||||
@router.get("/hint/{sentence_id}")
|
||||
async def get_typing_hint(request: Request, sentence_id: int):
|
||||
"""Возвращает правильный ответ для подсказки."""
|
||||
await require_auth(request)
|
||||
"""Возвращает правильный ответ для подсказки (лимит 1 раз)."""
|
||||
telegram_id, _ = await require_auth(request)
|
||||
|
||||
pool = await get_pool()
|
||||
async with pool.acquire() as conn:
|
||||
@@ -108,6 +108,21 @@ async def get_typing_hint(request: Request, sentence_id: int):
|
||||
""", sentence_id)
|
||||
if not row:
|
||||
raise HTTPException(404, "Sentence not found")
|
||||
|
||||
# 🔧 ФИКС (24.09.2026): typing_hint_no_limit — лимит 1 раз на предложение.
|
||||
already_used = await conn.fetchval(
|
||||
"SELECT 1 FROM typing_hints_used WHERE user_id = $1 AND sentence_id = $2",
|
||||
telegram_id, sentence_id
|
||||
)
|
||||
if already_used:
|
||||
raise HTTPException(403, "Hint already used for this sentence")
|
||||
|
||||
# Записываем использование
|
||||
await conn.execute("""
|
||||
INSERT INTO typing_hints_used (user_id, sentence_id)
|
||||
VALUES ($1, $2)
|
||||
ON CONFLICT (user_id, sentence_id) DO NOTHING
|
||||
""", telegram_id, sentence_id)
|
||||
|
||||
return {"correct_answer": row["sentence_pl"]}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user