forked from mtusi2026/mtusi2026lab2
lab 2 solution
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
"""Правила доступа: чужой объект неотличим от отсутствующего (404, не 403)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from uuid import UUID
|
||||
|
||||
from .domain import ChatRecord, UserRecord
|
||||
from .errors import not_found
|
||||
from .repository import Repository
|
||||
|
||||
|
||||
async def visible_chat(repository: Repository, chat_id: UUID, user: UserRecord) -> ChatRecord:
|
||||
"""Возвращает чат, если пользователь его участник, иначе 404."""
|
||||
chat = await repository.chat_for_member(chat_id, user.id)
|
||||
if chat is None:
|
||||
raise not_found("Чат не найден")
|
||||
return chat
|
||||
Reference in New Issue
Block a user