Завершить уровень 4: проверить отказы, поочерёдную замену и ограничить ожидания кэша
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user