Private
Public Access
Users can set a display name (shown instead of username in the message list, room member list, TopBar, and admin Users tab) and upload a real avatar, replacing the generated color-initial avatars everywhere a user appears. Avatars are square-cropped and downscaled to 512px, reusing app/storage.py's upload primitives from image uploads with a new square option. Two deliberate divergences from message-image handling, documented in backend/README.md: the previous avatar file is deleted on replace/remove (safe since it's strictly one file per user), and avatar serving is not room-gated and uses a short cache (identity-addressed and mutable, unlike a message image's permanent content-addressed URL). Frontend: new ProfileModal reachable from the TopBar account menu; AuthContext gains updateUser() so a profile change reflects instantly everywhere without a refetch.
51 lines
1.0 KiB
Python
51 lines
1.0 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, ConfigDict, EmailStr, Field
|
|
|
|
|
|
class AdminUserRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: uuid.UUID
|
|
username: str
|
|
email: EmailStr
|
|
is_bot: bool
|
|
is_site_admin: bool
|
|
is_active: bool
|
|
display_name: str | None
|
|
avatar_filename: str | None
|
|
created_at: datetime
|
|
|
|
|
|
class AdminRoomRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: uuid.UUID
|
|
name: str
|
|
description: str | None
|
|
is_private: bool
|
|
is_archived: bool
|
|
owner_id: uuid.UUID
|
|
created_at: datetime
|
|
member_count: int
|
|
|
|
|
|
class AuditLogEntryRead(BaseModel):
|
|
id: uuid.UUID
|
|
actor_id: uuid.UUID
|
|
actor_username: str
|
|
action: str
|
|
target_type: str
|
|
target_id: uuid.UUID
|
|
metadata: dict | None
|
|
created_at: datetime
|
|
|
|
|
|
class ResetPasswordRequest(BaseModel):
|
|
new_password: str = Field(min_length=8, max_length=200)
|
|
|
|
|
|
class TransferOwnershipRequest(BaseModel):
|
|
new_owner_id: uuid.UUID
|