from typing import TYPE_CHECKING from src import domain, dto if TYPE_CHECKING: from .. import Usecase async def archive_project(self: 'Usecase', input: dto.ArchiveProjectInput) -> dto.ProjectOutput: await self.ensure_workspace_permission( input.workspace_id, input.user_id, domain.PermissionKey.PROJECTS_WRITE, for_project_id=input.project_id ) async with self.database.transaction(): await self.database.archive_project(input.workspace_id, input.project_id) project = await self.database.get_project(input.workspace_id, project_id=input.project_id) if not project: raise domain.ProjectNotFound() await project.fetch_related('channel') return dto.ProjectOutput( id=project.id, telegram_id=project.channel.telegram_id, title=project.channel.title, username=project.channel.username, status=project.status, purchase_invite_type_default=project.purchase_invite_type_default, )