ref: рефакторинг usecases
This commit is contained in:
@@ -50,11 +50,11 @@ class Database(typing.Protocol):
|
||||
|
||||
async def get_user(self, user_id: UUID | None = None, telegram_id: int | None = None) -> domain.User | None: ...
|
||||
|
||||
async def create_user(self, user: domain.User) -> domain.User: ...
|
||||
async def create_user(self, user: domain.User) -> None: ...
|
||||
|
||||
async def create_login_token(
|
||||
self, user_id: UUID, token: str, expires_at: datetime.datetime
|
||||
) -> domain.LoginToken: ...
|
||||
async def create_login_token(self, login_token: domain.LoginToken) -> None: ...
|
||||
|
||||
async def create_creative(self, creative: domain.Creative) -> None: ...
|
||||
|
||||
async def get_login_token(self, token: str) -> domain.LoginToken | None: ...
|
||||
|
||||
@@ -64,17 +64,17 @@ class Database(typing.Protocol):
|
||||
self, user_id: UUID, channel_id: UUID | None = None, telegram_id: int | None = None
|
||||
) -> domain.TargetChannel | None: ...
|
||||
|
||||
async def upsert_target_channel(self, channel: domain.TargetChannel) -> domain.TargetChannel: ...
|
||||
async def upsert_target_channel(self, channel: domain.TargetChannel) -> None: ...
|
||||
|
||||
async def get_user_target_channels(self, user_id: UUID) -> list[domain.TargetChannel]: ...
|
||||
|
||||
async def update_target_channel(self, channel: domain.TargetChannel) -> domain.TargetChannel: ...
|
||||
async def update_target_channel(self, channel: domain.TargetChannel) -> None: ...
|
||||
|
||||
async def get_external_channel(
|
||||
self, user_id: UUID, channel_id: UUID | None = None, telegram_id: int | None = None
|
||||
) -> domain.ExternalChannel | None: ...
|
||||
|
||||
async def create_external_channel(self, channel: domain.ExternalChannel) -> domain.ExternalChannel: ...
|
||||
async def create_external_channel(self, channel: domain.ExternalChannel) -> None: ...
|
||||
|
||||
async def get_external_channels_for_target(self, target_channel_id: UUID) -> list[domain.ExternalChannel]: ...
|
||||
|
||||
@@ -88,13 +88,11 @@ class Database(typing.Protocol):
|
||||
|
||||
async def delete_external_channel(self, channel_id: UUID) -> None: ...
|
||||
|
||||
async def update_external_channel(self, channel: domain.ExternalChannel) -> domain.ExternalChannel: ...
|
||||
async def update_external_channel(self, channel: domain.ExternalChannel) -> None: ...
|
||||
|
||||
async def get_creative(self, user_id: UUID, creative_id: UUID) -> domain.Creative | None: ...
|
||||
|
||||
async def create_creative(self, creative: domain.Creative) -> domain.Creative: ...
|
||||
|
||||
async def update_creative(self, creative: domain.Creative) -> domain.Creative: ...
|
||||
async def update_creative(self, creative: domain.Creative) -> None: ...
|
||||
|
||||
async def get_user_creatives(
|
||||
self, user_id: UUID, target_channel_id: UUID | None = None, include_archived: bool = False
|
||||
@@ -104,9 +102,9 @@ class Database(typing.Protocol):
|
||||
|
||||
async def get_placement(self, user_id: UUID, placement_id: UUID) -> domain.Placement | None: ...
|
||||
|
||||
async def create_placement(self, placement: domain.Placement) -> domain.Placement: ...
|
||||
async def create_placement(self, placement: domain.Placement) -> None: ...
|
||||
|
||||
async def update_placement(self, placement: domain.Placement) -> domain.Placement: ...
|
||||
async def update_placement(self, placement: domain.Placement) -> None: ...
|
||||
|
||||
async def get_user_placements(
|
||||
self,
|
||||
@@ -123,17 +121,15 @@ class Database(typing.Protocol):
|
||||
|
||||
async def get_subscriber(self, telegram_id: int) -> domain.Subscriber | None: ...
|
||||
|
||||
async def create_subscriber(self, subscriber: domain.Subscriber) -> domain.Subscriber: ...
|
||||
async def upsert_subscriber(self, subscriber: domain.Subscriber) -> None: ...
|
||||
|
||||
async def upsert_subscriber(self, subscriber: domain.Subscriber) -> domain.Subscriber: ...
|
||||
|
||||
async def create_subscription(self, subscription: domain.Subscription) -> domain.Subscription: ...
|
||||
async def create_subscription(self, subscription: domain.Subscription) -> None: ...
|
||||
|
||||
async def get_subscription_by_subscriber_and_placement(
|
||||
self, subscriber_id: UUID, placement_id: UUID
|
||||
) -> domain.Subscription | None: ...
|
||||
|
||||
async def update_subscription(self, subscription: domain.Subscription) -> domain.Subscription: ...
|
||||
async def update_subscription(self, subscription: domain.Subscription) -> None: ...
|
||||
|
||||
async def get_active_subscriptions_by_subscriber_and_channel(
|
||||
self, subscriber_id: UUID, channel_telegram_id: int
|
||||
@@ -143,9 +139,7 @@ class Database(typing.Protocol):
|
||||
self, subscriber_id: UUID, channel_telegram_id: int
|
||||
) -> domain.Subscription | None: ...
|
||||
|
||||
async def create_placement_views_history(
|
||||
self, history: domain.PlacementViewsHistory
|
||||
) -> domain.PlacementViewsHistory: ...
|
||||
async def create_placement_views_history(self, history: domain.PlacementViewsHistory) -> None: ...
|
||||
|
||||
async def get_views_history(
|
||||
self,
|
||||
@@ -163,17 +157,6 @@ class Database(typing.Protocol):
|
||||
|
||||
async def clear_telegram_state(self, telegram_id: int) -> None: ...
|
||||
|
||||
# NATS-related methods for placement tracking
|
||||
async def get_placement_by_id(self, placement_id: UUID) -> domain.Placement | None: ...
|
||||
|
||||
async def update_placement_from_post_found(
|
||||
self, placement_id: UUID, ad_post_url: str, message_id: int, views_count: int
|
||||
) -> domain.Placement: ...
|
||||
|
||||
async def update_placement_from_post_deleted(self, placement_id: UUID) -> domain.Placement: ...
|
||||
|
||||
async def update_placement_views(self, placement_id: UUID, views_count: int) -> domain.Placement: ...
|
||||
|
||||
|
||||
class TelegramBotWriter(typing.Protocol):
|
||||
async def send_message(self, text: str, chat_id: int) -> None: ...
|
||||
@@ -186,8 +169,6 @@ class TelegramBotWriter(typing.Protocol):
|
||||
|
||||
async def edit_message_reply_markup(self, chat_id: int, message_id: int) -> None: ...
|
||||
|
||||
async def get_chat_member(self, chat_id: int, user_id: int) -> dict[str, typing.Any]: ...
|
||||
|
||||
async def create_chat_invite_link(self, chat_id: int, requires_approval: bool = False) -> str: ...
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user