25 lines
723 B
Python
25 lines
723 B
Python
from typing import TYPE_CHECKING
|
|
|
|
from src import dto
|
|
|
|
if TYPE_CHECKING:
|
|
from .. import Usecase
|
|
|
|
|
|
async def get_user_target_chans(self: 'Usecase', input: dto.GetUserTargetChansInput) -> dto.GetUserTargetChansOutput:
|
|
async with self.database.transaction():
|
|
channels = await self.database.get_user_target_channels(input.user_id)
|
|
|
|
return dto.GetUserTargetChansOutput(
|
|
target_channels=[
|
|
dto.ConnectTargetChanOutput(
|
|
id=channel.id,
|
|
telegram_id=channel.telegram_id,
|
|
title=channel.title,
|
|
username=channel.username,
|
|
is_active=channel.is_active,
|
|
)
|
|
for channel in channels
|
|
]
|
|
)
|