All checks were successful
CI / test (push) Successful in 32s
- add owner/admin/member permission checks - implement member add/remove, role updates, and leave flow - add chat title update endpoint for manageable chat types
46 lines
937 B
Python
46 lines
937 B
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
|
|
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)
|