Files
Messenger/app/realtime/schemas.py
benya 99e7c70901
Some checks failed
CI / test (push) Failing after 21s
feat: realtime sync, settings UX and chat list improvements
- add chat_updated realtime event and dynamic chat subscriptions

- auto-join invite links in web app

- implement Telegram-like settings panel (general/notifications/privacy)

- add browser notification preferences and keyboard send mode

- improve chat list with last message preview/time and online badge

- rework chat members UI with context actions and role crowns
2026-03-08 10:59:44 +03:00

55 lines
1.2 KiB
Python

from datetime import datetime
from typing import Any, Literal
from pydantic import BaseModel, ConfigDict, Field
from app.messages.models import MessageType
RealtimeEventName = Literal[
"connect",
"disconnect",
"send_message",
"receive_message",
"typing_start",
"typing_stop",
"message_read",
"message_delivered",
"user_online",
"user_offline",
"chat_updated",
"pong",
"error",
]
class SendMessagePayload(BaseModel):
chat_id: int
type: MessageType = MessageType.TEXT
text: str | None = Field(default=None, max_length=4096)
temp_id: str | None = None
client_message_id: str | None = Field(default=None, min_length=8, max_length=64)
reply_to_message_id: int | None = None
class ChatEventPayload(BaseModel):
chat_id: int
class MessageStatusPayload(BaseModel):
chat_id: int
message_id: int
class IncomingRealtimeEvent(BaseModel):
event: Literal["send_message", "typing_start", "typing_stop", "message_read", "message_delivered", "ping"]
payload: dict[str, Any]
class OutgoingRealtimeEvent(BaseModel):
model_config = ConfigDict(from_attributes=True)
event: RealtimeEventName
payload: dict[str, Any]
timestamp: datetime