feat: add models and partially custom error messages

This commit is contained in:
firedotguy
2026-01-31 12:10:20 +03:00
parent c7e3812ee8
commit a388426d8d
15 changed files with 352 additions and 71 deletions

View File

@@ -3,6 +3,25 @@ from datetime import datetime
from pydantic import BaseModel, Field
class UserPrivacy(BaseModel):
private: bool | None = Field(None, alias='isPrivate') # none for not me
wall_closed: bool = Field(False, alias='wallClosed')
model_config = {'populate_by_name': True}
class UserProfileUpdate(BaseModel):
id: UUID
username: str
display_name: str = Field(alias='displayName')
bio: str | None = None
updated_at: datetime | None = Field(None, alias='updatedAt')
model_config = {'populate_by_name': True}
class UserNotification(BaseModel):
id: UUID
username: str
@@ -16,22 +35,26 @@ class UserPost(UserNotification):
verified: bool = False
class UserSearch(UserPost):
class UserWhoToFollow(UserPost):
followers_count: int = Field(0, alias='followersCount')
class User(UserSearch):
class UserFollower(UserPost):
is_following: bool = Field(False, alias='isFollowing') # none for me
class UserSearch(UserFollower, UserWhoToFollow):
pass
class User(UserSearch, UserPrivacy):
banner: str | None = None
bio: str | None = None
pinned_post_id: UUID | None
private: bool | None = Field(None, alias='isPrivate') # none for not me
wall_closed: bool = Field(False, alias='wallClosed')
pinned_post_id: UUID | None = Field(None, alias='pinnedPostId')
following_count: int = Field(0, alias='followingCount')
posts_count: int = Field(0, alias='postsCount')
is_following: bool | None = Field(None, alias='isFollowing') # none for me
is_followed: bool | None = Field(None, alias='isFollowedBy') # none for me
created_at: datetime = Field(alias='createdAt')