feat: миграция с булевых переменных на status для target_channel
This commit is contained in:
@@ -57,7 +57,7 @@ async def connect_target_chan(self: 'Usecase', input: dto.ConnectTargetChanInput
|
||||
title=input.title,
|
||||
username=input.username,
|
||||
user_id=user.id,
|
||||
is_active=True,
|
||||
status=domain.TargetChannelStatus.ACTIVE,
|
||||
)
|
||||
|
||||
upserted_channel = await self.database.upsert_target_channel(channel)
|
||||
@@ -73,5 +73,6 @@ async def connect_target_chan(self: 'Usecase', input: dto.ConnectTargetChanInput
|
||||
telegram_id=upserted_channel.telegram_id,
|
||||
title=upserted_channel.title,
|
||||
username=upserted_channel.username,
|
||||
is_active=upserted_channel.is_active,
|
||||
status=upserted_channel.status,
|
||||
is_active=upserted_channel.status == domain.TargetChannelStatus.ACTIVE,
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@ async def disconnect_target_chan(self: 'Usecase', input: dto.DisconnectTargetCha
|
||||
if not channel:
|
||||
raise domain.TargetChannelNotFound(input.channel_id)
|
||||
|
||||
channel.is_active = False
|
||||
channel.status = domain.TargetChannelStatus.INACTIVE
|
||||
await self.database.update_target_channel(channel)
|
||||
|
||||
log.info(f'Target channel {input.channel_id} deactivated')
|
||||
|
||||
@@ -21,7 +21,7 @@ async def disconnect_target_chan_by_tg_id(self: 'Usecase', input: dto.Disconnect
|
||||
log.warning(f'Target channel {input.telegram_id} not found')
|
||||
raise domain.TargetChannelNotFound()
|
||||
|
||||
channel.is_active = False
|
||||
channel.status = domain.TargetChannelStatus.INACTIVE
|
||||
await self.database.update_target_channel(channel)
|
||||
|
||||
log.info(f'Target channel {input.telegram_id} deactivated')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from src import dto
|
||||
from src import domain, dto
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .. import Usecase
|
||||
@@ -17,7 +17,8 @@ async def get_user_target_chans(self: 'Usecase', input: dto.GetUserTargetChansIn
|
||||
telegram_id=channel.telegram_id,
|
||||
title=channel.title,
|
||||
username=channel.username,
|
||||
is_active=channel.is_active,
|
||||
status=channel.status,
|
||||
is_active=channel.status == domain.TargetChannelStatus.ACTIVE,
|
||||
)
|
||||
for channel in channels
|
||||
]
|
||||
|
||||
@@ -29,8 +29,8 @@ async def update_target_chan_permissions(self: 'Usecase', input: dto.UpdateTarge
|
||||
raise domain.TargetChannelNotFound()
|
||||
|
||||
if not missing_permissions:
|
||||
if not channel.is_active:
|
||||
channel.is_active = True
|
||||
if channel.status != domain.TargetChannelStatus.ACTIVE:
|
||||
channel.status = domain.TargetChannelStatus.ACTIVE
|
||||
await self.database.update_target_channel(channel)
|
||||
|
||||
await self.telegram_bot.send_message(
|
||||
@@ -40,8 +40,8 @@ async def update_target_chan_permissions(self: 'Usecase', input: dto.UpdateTarge
|
||||
log.info(f'Target channel {input.telegram_id} reactivated - all permissions granted')
|
||||
return
|
||||
|
||||
if channel.is_active:
|
||||
channel.is_active = False
|
||||
if channel.status == domain.TargetChannelStatus.ACTIVE:
|
||||
channel.status = domain.TargetChannelStatus.INACTIVE
|
||||
await self.database.update_target_channel(channel)
|
||||
|
||||
missed_permissions = '\n'.join(f'• {p}' for p in missing_permissions)
|
||||
|
||||
Reference in New Issue
Block a user