feat: update privacy data
This commit is contained in:
@@ -4,13 +4,41 @@ from datetime import datetime
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from itd.models.pin import ShortPin
|
||||
from itd.enums import AccessType
|
||||
|
||||
|
||||
class UserPrivacy(BaseModel):
|
||||
class _UserPrivacy(BaseModel):
|
||||
private: bool | None = Field(None, alias='isPrivate') # none for not me
|
||||
wall_closed: bool = Field(False, alias='wallClosed')
|
||||
wall_closed: bool | None = Field(None, alias='wallClosed', deprecated=True)
|
||||
wall_access: AccessType = Field(AccessType.EVERYONE, alias='wallAccess')
|
||||
likes_visibility: AccessType = Field(AccessType.EVERYONE, alias='likesVisibility')
|
||||
|
||||
model_config = {'populate_by_name': True}
|
||||
model_config = {'serialize_by_alias': True}
|
||||
|
||||
|
||||
class UserPrivacy(_UserPrivacy):
|
||||
show_last_seen: bool = Field(True, alias='showLastSeen')
|
||||
|
||||
|
||||
class UserPrivacyData:
|
||||
def __init__(self, private: bool | None = None, wall_access: AccessType | None = None, likes_visibility: AccessType | None = None, show_last_seen: bool | None = None) -> None:
|
||||
self.private = private
|
||||
self.wall_access = wall_access
|
||||
self.likes_visibility = likes_visibility
|
||||
self.show_last_seen = show_last_seen
|
||||
|
||||
def to_dict(self):
|
||||
data = {}
|
||||
if self.private is not None:
|
||||
data['isPrivate'] = self.private
|
||||
if self.wall_access is not None:
|
||||
data['wallAccess'] = self.wall_access.value
|
||||
if self.likes_visibility is not None:
|
||||
data['likesVisibility'] = self.likes_visibility.value
|
||||
if self.show_last_seen is not None:
|
||||
data['showLastSeen'] = self.show_last_seen
|
||||
|
||||
return data
|
||||
|
||||
|
||||
class UserProfileUpdate(BaseModel):
|
||||
@@ -51,7 +79,7 @@ class UserSearch(UserFollower, UserWhoToFollow):
|
||||
pass
|
||||
|
||||
|
||||
class User(UserSearch, UserPrivacy):
|
||||
class User(UserSearch, _UserPrivacy):
|
||||
banner: str | None = None
|
||||
bio: str | None = None
|
||||
pinned_post_id: UUID | None = Field(None, alias='pinnedPostId')
|
||||
@@ -62,3 +90,5 @@ class User(UserSearch, UserPrivacy):
|
||||
is_followed: bool | None = Field(None, alias='isFollowedBy') # none for me
|
||||
|
||||
created_at: datetime = Field(alias='createdAt')
|
||||
last_seen_at: datetime | None = Field(None, alias='lastSeen')
|
||||
online: bool = False
|
||||
|
||||
Reference in New Issue
Block a user