diff --git a/src/application/commands/__init__.py b/src/application/commands/__init__.py index d8ffd8b..7942e71 100644 --- a/src/application/commands/__init__.py +++ b/src/application/commands/__init__.py @@ -10,3 +10,6 @@ from src.application.commands.purchase_request_commands import ( GetPurchaseRequestCommand, ListPurchaseRequestsCommand, ) +from src.application.commands.upload_docs_button import ( + UploadDocsCommand, +) diff --git a/src/application/commands/upload_docs_button.py b/src/application/commands/upload_docs_button.py index f774635..3e542bb 100644 --- a/src/application/commands/upload_docs_button.py +++ b/src/application/commands/upload_docs_button.py @@ -22,11 +22,9 @@ class UploadDocsCommand: @transactional async def __call__( self, - user_id: str, *, comment: str | None = None, ) -> None: - legal_entity = await require_legal_entity(user_id, self._unit_of_work) message_id = str(ULID()) now = datetime.now(timezone.utc).isoformat() metadata = { @@ -34,15 +32,13 @@ class UploadDocsCommand: 'timestamp': now, 'message_id': message_id, } - payload = { - 'id_client': legal_entity.id, - } + payload = {} message = { 'event': 'docs_upload', 'payload': payload, 'metadata': metadata, } - self._logger.info(f'Upload docs for organization_id={legal_entity.id}') + self._logger.info(f'New client uploaded docs, sending notification to telegram') try: await self._messanger.publish_to_queue( queue=settings.RABBIT_TELEGRAM_NOTIFY_QUEUE, diff --git a/src/presentation/dependencies/commands.py b/src/presentation/dependencies/commands.py index fa3270b..23d1af7 100644 --- a/src/presentation/dependencies/commands.py +++ b/src/presentation/dependencies/commands.py @@ -9,6 +9,7 @@ from src.application.commands import ( GetPurchaseRequestCommand, ListOrganizationWalletsCommand, ListPurchaseRequestsCommand, + UploadDocsCommand, ) from src.application.contracts import ILogger, IQueueMessanger from src.infrastructure.wallet_balances import WalletBalanceService @@ -76,3 +77,10 @@ def get_get_organization_secret_keys_command( unit_of_work: IUnitOfWork = Depends(get_unit_of_work), ) -> GetOrganizationSecretKeysCommand: return GetOrganizationSecretKeysCommand(unit_of_work=unit_of_work, logger=logger) + +def get_upload_docs_command( + logger: ILogger = Depends(get_logger), + unit_of_work: IUnitOfWork = Depends(get_unit_of_work), + messanger: IQueueMessanger = Depends(get_queue_messanger), +) -> UploadDocsCommand: + return UploadDocsCommand(unit_of_work=unit_of_work, logger=logger, messanger=messanger) diff --git a/src/presentation/routing/__init__.py b/src/presentation/routing/__init__.py index 35702eb..1b9524a 100644 --- a/src/presentation/routing/__init__.py +++ b/src/presentation/routing/__init__.py @@ -2,8 +2,10 @@ from fastapi import APIRouter from src.presentation.routing.organizations import organizations_router from src.presentation.routing.purchase_requests import purchase_requests_router +from src.presentation.routing.documents import upload_docs_router v1_router = APIRouter(prefix='/v1') v1_router.include_router(organizations_router) +v1_router.include_router(upload_docs_router) -__all__ = ['purchase_requests_router', 'organizations_router', 'v1_router'] +__all__ = ['purchase_requests_router', 'organizations_router', 'upload_docs_router', 'v1_router'] diff --git a/src/presentation/routing/documents.py b/src/presentation/routing/documents.py new file mode 100644 index 0000000..0241da5 --- /dev/null +++ b/src/presentation/routing/documents.py @@ -0,0 +1,17 @@ +from fastapi import APIRouter, Depends + +from src.application.commands import ( + UploadDocsCommand, +) +from src.presentation.dependencies.commands import ( + get_upload_docs_command, +) + +upload_docs_router = APIRouter(prefix='/upload-docs', tags=['upload-docs']) + +@upload_docs_router.post('') +async def upload_docs( + command: UploadDocsCommand = Depends(get_upload_docs_command), +): + await command() + return {'message': 'Documents uploaded successfully.'} \ No newline at end of file