feat(link_codes): linking method between telegram and website
This commit is contained in:
@@ -16,3 +16,12 @@ class AuthContext:
|
||||
user: User
|
||||
auth_method: Literal["jwt", "service"]
|
||||
service: str | None = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class ServiceIdentity:
|
||||
"""
|
||||
Proves that request is coming from verified source, no user context provided.
|
||||
"""
|
||||
|
||||
service: str
|
||||
|
||||
@@ -9,3 +9,9 @@ class SubscriptionStatus(StrEnum):
|
||||
class ServiceSignatureStatus(StrEnum):
|
||||
ACTIVE = "active"
|
||||
INACTIVE = "inactive"
|
||||
|
||||
|
||||
class LinkCodeStatus(StrEnum):
|
||||
ACTIVE = "active"
|
||||
USED = "used"
|
||||
EXPIRED = "expired"
|
||||
|
||||
20
schemas/link_codes.py
Normal file
20
schemas/link_codes.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, Field, computed_field
|
||||
|
||||
from config import cfg
|
||||
|
||||
|
||||
class LinkCodeResponse(BaseModel):
|
||||
code: str = Field()
|
||||
expires_at: datetime = Field()
|
||||
|
||||
@computed_field
|
||||
@property
|
||||
def deep_link(self) -> str:
|
||||
return cfg.bot_url + "?start=" + self.code
|
||||
|
||||
|
||||
class LinkCodeConsume(BaseModel):
|
||||
code: str = Field()
|
||||
telegram_id: int = Field()
|
||||
Reference in New Issue
Block a user