Завершить уровень 4: проверить отказы, поочерёдную замену и ограничить ожидания кэша

This commit is contained in:
2026-10-23 19:09:56 +03:00
parent bdcf00a412
commit d30f418cec
33 changed files with 1962 additions and 40 deletions
+7 -2
View File
@@ -1,5 +1,6 @@
from uuid import UUID
import re
import os
from fastapi import APIRouter, Depends, HTTPException, Request
@@ -21,8 +22,12 @@ def create_message(
request_id = get_request_id(request)
chat_id_str = str(chat_id)
chat = storage.get_chat(chat_id_str)
if not chat or x_user_id not in chat.member_ids:
if os.getenv('OPTIMIZED_WRITES','1') == '1':
allowed = storage.is_chat_member(chat_id_str, x_user_id)
else:
chat = storage.get_chat(chat_id_str)
allowed = bool(chat and x_user_id in chat.member_ids)
if not allowed:
raise HTTPException(
status_code=404,
detail=make_error("not_found", "чат не найден", request_id).model_dump(),