Some checks failed
CI / test (push) Failing after 17s
backend: - add required user name and optional bio fields - extend auth/register and user schemas/services with name/bio - add alembic migration 0006 with safe backfill name=username - compute per-user chat display_title for private chats - keep Saved Messages delete-for-all protections web: - registration now includes name - add profile edit modal (name/username/bio/avatar url) - show private chat names via display_title - fix context menus to open near cursor with viewport clamping - stabilize +/close floating button to remove visual jump
67 lines
1.5 KiB
Python
67 lines
1.5 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
|
|
display_title: str | None = None
|
|
handle: str | None = None
|
|
description: str | None = None
|
|
is_public: bool = False
|
|
is_saved: bool = False
|
|
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)
|
|
handle: str | None = Field(default=None, max_length=64)
|
|
description: str | None = Field(default=None, max_length=512)
|
|
is_public: bool = False
|
|
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
|
|
|
|
|
|
class ChatDeleteRequest(BaseModel):
|
|
for_all: bool = False
|
|
|
|
|
|
class ChatDiscoverRead(ChatRead):
|
|
is_member: bool
|