Отедельные таблицы User и TelegramUser
This commit is contained in:
@@ -65,6 +65,16 @@ class Database(typing.Protocol):
|
||||
|
||||
async def create_user(self, user: domain.User) -> None: ...
|
||||
|
||||
async def get_telegram_user(
|
||||
self,
|
||||
telegram_user_id: UUID | None = None,
|
||||
telegram_id: int | None = None,
|
||||
) -> domain.TelegramUser | None: ...
|
||||
|
||||
async def create_telegram_user(self, telegram_user: domain.TelegramUser) -> None: ...
|
||||
|
||||
async def update_telegram_user(self, telegram_user: domain.TelegramUser) -> None: ...
|
||||
|
||||
async def create_workspace(self, workspace: domain.Workspace) -> None: ...
|
||||
|
||||
async def update_workspace(self, workspace: domain.Workspace) -> None: ...
|
||||
@@ -222,7 +232,7 @@ class Database(typing.Protocol):
|
||||
async def create_subscription(self, subscription: domain.Subscription) -> None: ...
|
||||
|
||||
async def get_subscription_by_subscriber_and_placement(
|
||||
self, subscriber_id: UUID, placement_id: UUID
|
||||
self, telegram_user_id: UUID, placement_id: UUID
|
||||
) -> domain.Subscription | None: ...
|
||||
|
||||
async def update_subscription(self, subscription: domain.Subscription) -> None: ...
|
||||
@@ -236,11 +246,11 @@ class Database(typing.Protocol):
|
||||
) -> list[domain.Subscription]: ...
|
||||
|
||||
async def get_active_subscriptions_by_subscriber_and_project(
|
||||
self, subscriber_id: UUID, project_id: UUID
|
||||
self, telegram_user_id: UUID, project_id: UUID
|
||||
) -> list[domain.Subscription]: ...
|
||||
|
||||
async def get_active_subscription_by_subscriber_and_project(
|
||||
self, subscriber_id: UUID, project_id: UUID
|
||||
self, telegram_user_id: UUID, project_id: UUID
|
||||
) -> domain.Subscription | None: ...
|
||||
|
||||
# Count methods
|
||||
@@ -365,7 +375,11 @@ class Usecase:
|
||||
if workspace:
|
||||
return workspace
|
||||
|
||||
workspace_name = user.username or f'Workspace {user.telegram_id}'
|
||||
if not user.telegram_user:
|
||||
raise domain.UserNotFound(user.id)
|
||||
|
||||
telegram_user = user.telegram_user
|
||||
workspace_name = telegram_user.username or f'Workspace {telegram_user.telegram_id}'
|
||||
workspace = domain.Workspace(name=workspace_name)
|
||||
|
||||
async with self.database.transaction():
|
||||
|
||||
Reference in New Issue
Block a user