feat: удаление target chan только через telegram
This commit is contained in:
9
Makefile
9
Makefile
@@ -11,6 +11,15 @@ up:
|
|||||||
migrate:
|
migrate:
|
||||||
docker exec -it tgex-backend-backend-1 .venv/bin/alembic upgrade head
|
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:
|
down:
|
||||||
docker compose down
|
docker compose down
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import uuid
|
|
||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
|
|
||||||
from fastapi import Depends
|
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)
|
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)
|
|
||||||
|
|||||||
@@ -43,11 +43,6 @@ class GetUserTargetChansOutput(pydantic.BaseModel):
|
|||||||
target_channels: list[ConnectTargetChanOutput]
|
target_channels: list[ConnectTargetChanOutput]
|
||||||
|
|
||||||
|
|
||||||
class DisconnectTargetChanInput(pydantic.BaseModel):
|
|
||||||
channel_id: uuid.UUID
|
|
||||||
user_id: uuid.UUID
|
|
||||||
|
|
||||||
|
|
||||||
class DisconnectTargetChanByTgIdInput(pydantic.BaseModel):
|
class DisconnectTargetChanByTgIdInput(pydantic.BaseModel):
|
||||||
telegram_id: int
|
telegram_id: int
|
||||||
user_telegram_id: int
|
user_telegram_id: int
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ from .placement.update_placement import update_placement
|
|||||||
from .subscription.handle_subscription import handle_subscription
|
from .subscription.handle_subscription import handle_subscription
|
||||||
from .subscription.handle_unsubscription import handle_unsubscription
|
from .subscription.handle_unsubscription import handle_unsubscription
|
||||||
from .target_channel.connect_target_chan import connect_target_chan
|
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.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.get_user_target_chans import get_user_target_chans
|
||||||
from .target_channel.update_target_chan_permissions import update_target_chan_permissions
|
from .target_channel.update_target_chan_permissions import update_target_chan_permissions
|
||||||
@@ -188,7 +187,6 @@ class Usecase:
|
|||||||
get_me = get_me
|
get_me = get_me
|
||||||
connect_target_chan = connect_target_chan
|
connect_target_chan = connect_target_chan
|
||||||
get_user_target_chans = get_user_target_chans
|
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
|
disconnect_target_chan_by_tg_id = disconnect_target_chan_by_tg_id
|
||||||
update_target_chan_permissions = update_target_chan_permissions
|
update_target_chan_permissions = update_target_chan_permissions
|
||||||
get_external_channels = get_external_channels
|
get_external_channels = get_external_channels
|
||||||
|
|||||||
@@ -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')
|
|
||||||
Reference in New Issue
Block a user