feat(/me): subscription data + rw controls

This commit is contained in:
2026-08-03 11:15:11 +07:00
parent 801014c392
commit c06be7b5f2
11 changed files with 142 additions and 73 deletions

View File

@@ -1,16 +1,21 @@
from datetime import datetime
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, computed_field
class SubscriptionData(BaseModel):
devices: int = Field()
expires_at: datetime = Field()
addon_ids: list[str] = Field()
devices: int | None = Field(None)
expires_at: datetime | None = Field(None)
addon_ids: list[str] = Field(default_factory=list)
subscription_link: str | None = Field(None)
@property
@computed_field
def has_subscription(self) -> bool:
return all([self.devices, self.expires_at, self.subscription_link, self.addon_ids])
class UserInfo(BaseModel):
username: str | None = Field(None)
telegram_id: str | None = Field(None)
subscription: SubscriptionData | None = Field(None)
referal_code: str = Field()