feat: creatives and external channels
This commit is contained in:
28
src/usecase/creative/get_creative.py
Normal file
28
src/usecase/creative/get_creative.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from src import domain, dto
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .. import Usecase
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def get_creative(self: 'Usecase', input: dto.GetCreativeInput) -> dto.CreativeOutput:
|
||||
async with self.database.transaction():
|
||||
creative = await self.database.get_creative(input.user_id, input.creative_id)
|
||||
if not creative:
|
||||
log.warning('User %s attempted to access unavailable creative %s', input.user_id, input.creative_id)
|
||||
raise domain.CreativeNotFound(input.creative_id)
|
||||
|
||||
return dto.CreativeOutput(
|
||||
id=creative.id,
|
||||
name=creative.name,
|
||||
text=creative.text,
|
||||
target_channel_id=creative.target_channel_id,
|
||||
target_channel_title=creative.target_channel.title,
|
||||
created_at=creative.created_at,
|
||||
status=creative.status,
|
||||
purchases_count=creative.purchases_count,
|
||||
)
|
||||
Reference in New Issue
Block a user