feat: переименование доменной области

This commit is contained in:
Artem Tsyrulnikov
2025-12-14 12:21:35 +03:00
parent 3cb3da4dbe
commit f3e09a08eb
75 changed files with 1624 additions and 1417 deletions

View File

@@ -22,16 +22,23 @@ async def handle_subscription(
log.warning('Placement not found for invite_link: %s', invite_link)
return
subscriber = domain.Subscriber(
telegram_id=user_telegram_id,
username=username,
first_name=first_name,
last_name=last_name,
)
await self.database.upsert_subscriber(subscriber)
subscriber = await self.database.get_user(telegram_id=user_telegram_id)
if not subscriber:
subscriber = domain.User(
telegram_id=user_telegram_id,
username=username,
first_name=first_name,
last_name=last_name,
)
await self.database.create_user(subscriber)
else:
subscriber.username = username or subscriber.username
subscriber.first_name = first_name or subscriber.first_name
subscriber.last_name = last_name or subscriber.last_name
await self.database.update_user(subscriber)
active_subscription = await self.database.get_active_subscription_by_subscriber_and_channel(
subscriber.id, placement.target_channel.telegram_id
active_subscription = await self.database.get_active_subscription_by_subscriber_and_project(
subscriber.id, placement.project_id
)
if active_subscription:
@@ -43,7 +50,7 @@ async def handle_subscription(
'ignoring new subscription attempt via placement %s',
subscriber.id,
user_telegram_id,
placement.target_channel_id,
placement.project_id,
active_subscription.placement_id,
placement.id,
)
@@ -72,7 +79,6 @@ async def handle_subscription(
subscription = domain.Subscription(
placement_id=placement.id,
subscriber_id=subscriber.id,
target_channel_id=placement.target_channel_id,
invite_link=invite_link,
)
async with self.database.transaction():

View File

@@ -12,14 +12,17 @@ log = logging.getLogger(__name__)
async def handle_unsubscription(self: 'Usecase', user_telegram_id: int, channel_telegram_id: int) -> None:
subscriber = await self.database.get_subscriber(user_telegram_id)
subscriber = await self.database.get_user(telegram_id=user_telegram_id)
if not subscriber:
log.warning('Subscriber not found for telegram_id: %s', user_telegram_id)
return
subscriptions = await self.database.get_active_subscriptions_by_subscriber_and_channel(
subscriber.id, channel_telegram_id
)
project = await self.database.get_project_by_channel_telegram(channel_telegram_id)
if not project:
log.warning('Project not found for channel telegram_id: %s', channel_telegram_id)
return
subscriptions = await self.database.get_active_subscriptions_by_subscriber_and_project(subscriber.id, project.id)
if not subscriptions:
log.info(