feat: полный patch External Channel архивирование creative в patch и

purchase, удалить у них доп ручки/usecase/dto
This commit is contained in:
Artem Tsyrulnikov
2025-11-11 23:10:08 +03:00
parent f5d2e262f0
commit 552a3ddef2
14 changed files with 80 additions and 117 deletions

View File

@@ -0,0 +1,42 @@
import logging
import uuid
from typing import TYPE_CHECKING
from src import domain, dto
if TYPE_CHECKING:
from .. import Usecase
log = logging.getLogger(__name__)
async def update_external_channel(
self: 'Usecase', channel_id: uuid.UUID, input: dto.UpdateExternalChannelInput, user_id: uuid.UUID
) -> dto.ExternalChannelOutput:
async with self.database.transaction():
external_channel = await self.database.get_external_channel(user_id, channel_id=channel_id)
if not external_channel:
log.warning('External channel %s not found', channel_id)
raise domain.ExternalChannelNotFound(channel_id)
if input.title is not None:
external_channel.title = input.title
if input.username is not None:
external_channel.username = input.username
if input.description is not None:
external_channel.description = input.description
if input.subscribers_count is not None:
external_channel.subscribers_count = input.subscribers_count
updated = await self.database.update_external_channel(external_channel)
log.info('External channel %s updated', channel_id)
return dto.ExternalChannelOutput(
id=updated.id,
telegram_id=updated.telegram_id,
title=updated.title,
username=updated.username,
description=updated.description,
subscribers_count=updated.subscribers_count,
)