feat: удаление target chan только через telegram

This commit is contained in:
Artem Tsyrulnikov
2025-12-11 18:16:21 +03:00
parent 1f80d9bdfb
commit eb1005c995
5 changed files with 9 additions and 41 deletions

View File

@@ -11,6 +11,15 @@ up:
migrate:
docker exec -it tgex-backend-backend-1 .venv/bin/alembic upgrade head
migrate-init:
export $$(cat .env | xargs) && aerich init-db
migrate-create:
export $$(cat .env | xargs) && aerich migrate
migrate-up:
export $$(cat .env | xargs) && aerich upgrade
down:
docker compose down

View File

@@ -1,4 +1,3 @@
import uuid
from typing import Annotated
from fastapi import Depends
@@ -19,16 +18,3 @@ async def get_user_target_chans(
)
return await deps.get_usecase().get_user_target_chans(input=input)
@target_channels_router.delete('/{channel_id}')
async def disconnect_target_chan(
channel_id: uuid.UUID,
current_user: Annotated[JWTPayload, Depends(deps.get_current_user)],
) -> None:
input = dto.DisconnectTargetChanInput(
channel_id=channel_id,
user_id=current_user.user_id,
)
await deps.get_usecase().disconnect_target_chan(input=input)

View File

@@ -43,11 +43,6 @@ class GetUserTargetChansOutput(pydantic.BaseModel):
target_channels: list[ConnectTargetChanOutput]
class DisconnectTargetChanInput(pydantic.BaseModel):
channel_id: uuid.UUID
user_id: uuid.UUID
class DisconnectTargetChanByTgIdInput(pydantic.BaseModel):
telegram_id: int
user_telegram_id: int

View File

@@ -37,7 +37,6 @@ from .placement.update_placement import update_placement
from .subscription.handle_subscription import handle_subscription
from .subscription.handle_unsubscription import handle_unsubscription
from .target_channel.connect_target_chan import connect_target_chan
from .target_channel.disconnect_target_chan import disconnect_target_chan
from .target_channel.disconnect_target_chan_by_tg_id import disconnect_target_chan_by_tg_id
from .target_channel.get_user_target_chans import get_user_target_chans
from .target_channel.update_target_chan_permissions import update_target_chan_permissions
@@ -188,7 +187,6 @@ class Usecase:
get_me = get_me
connect_target_chan = connect_target_chan
get_user_target_chans = get_user_target_chans
disconnect_target_chan = disconnect_target_chan
disconnect_target_chan_by_tg_id = disconnect_target_chan_by_tg_id
update_target_chan_permissions = update_target_chan_permissions
get_external_channels = get_external_channels

View File

@@ -1,20 +0,0 @@
import logging
from typing import TYPE_CHECKING
from src import domain, dto
if TYPE_CHECKING:
from .. import Usecase
log = logging.getLogger(__name__)
async def disconnect_target_chan(self: 'Usecase', input: dto.DisconnectTargetChanInput) -> None:
channel = await self.database.get_target_channel(channel_id=input.channel_id, user_id=input.user_id)
if not channel:
raise domain.TargetChannelNotFound(input.channel_id)
channel.status = domain.TargetChannelStatus.INACTIVE
await self.database.update_target_channel(channel)
log.info(f'Target channel {input.channel_id} deactivated')