forked from mtusi2026/mtusi2026lab5
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
from collections.abc import Sequence
|
|
from datetime import datetime
|
|
from typing import Protocol, runtime_checkable
|
|
from uuid import UUID
|
|
|
|
from messenger.messaging.domain.keys import HistoryKey
|
|
from messenger.messaging.domain.models import Chat, Message, Receipt
|
|
from messenger.shared.application.ports import UnitOfWork
|
|
|
|
|
|
@runtime_checkable
|
|
class CursorCodec(Protocol):
|
|
def encode(self, scope: str, key: HistoryKey) -> str: ...
|
|
|
|
def decode(self, scope: str, raw: str) -> HistoryKey: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class ChatRepository(Protocol):
|
|
async def add(self, chat: Chat) -> None: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class MessageLog(Protocol):
|
|
async def post(
|
|
self, message: Message, key: str, fingerprint: bytes, since: datetime
|
|
) -> Receipt | None: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class MessagingUnitOfWork(UnitOfWork, Protocol):
|
|
@property
|
|
def chats(self) -> ChatRepository: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class AttachmentStates(Protocol):
|
|
async def unusable(self, chat_id: UUID, attachment_ids: Sequence[UUID]) -> bool: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class ChatDirectory(Protocol):
|
|
async def chat_for_member(self, chat_id: UUID, user_id: UUID) -> Chat | None: ...
|
|
|
|
async def chats_of(
|
|
self, user_id: UUID, *, after: HistoryKey | None, limit: int
|
|
) -> tuple[list[Chat], bool]: ...
|
|
|
|
async def history(
|
|
self, chat_id: UUID, *, after: HistoryKey | None, limit: int
|
|
) -> tuple[list[Message], bool]: ...
|