Some checks failed
CI / test (push) Failing after 24s
- add reply_to/forwarded_from message fields and chat pinned_message field - add forward and pin APIs plus reply support in message create - wire web actions: Reply, Fwd, Pin and reply composer state - fix spam policy bug: allow repeated identical messages, keep rate limiting
51 lines
1.0 KiB
Python
51 lines
1.0 KiB
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
from app.chats.models import ChatMemberRole, ChatType
|
|
|
|
|
|
class ChatRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
type: ChatType
|
|
title: str | None = None
|
|
pinned_message_id: int | None = None
|
|
created_at: datetime
|
|
|
|
|
|
class ChatMemberRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
user_id: int
|
|
role: ChatMemberRole
|
|
joined_at: datetime
|
|
|
|
|
|
class ChatDetailRead(ChatRead):
|
|
members: list[ChatMemberRead]
|
|
|
|
|
|
class ChatCreateRequest(BaseModel):
|
|
type: ChatType
|
|
title: str | None = Field(default=None, max_length=255)
|
|
member_ids: list[int] = Field(default_factory=list)
|
|
|
|
|
|
class ChatMemberAddRequest(BaseModel):
|
|
user_id: int
|
|
|
|
|
|
class ChatMemberRoleUpdateRequest(BaseModel):
|
|
role: ChatMemberRole
|
|
|
|
|
|
class ChatTitleUpdateRequest(BaseModel):
|
|
title: str = Field(min_length=1, max_length=255)
|
|
|
|
|
|
class ChatPinMessageRequest(BaseModel):
|
|
message_id: int | None = None
|