From 109bbb1a9c4e0a46342d31baa0284176d683a3fb Mon Sep 17 00:00:00 2001 From: Jackson Barbosa Date: Fri, 8 Dec 2023 11:29:18 -0300 Subject: [PATCH] remove from celery task update description --- connect/api/v1/project/serializers.py | 8 ++++++++ connect/api/v2/projects/serializers.py | 16 ++++++++++++++-- connect/common/tasks.py | 9 +-------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/connect/api/v1/project/serializers.py b/connect/api/v1/project/serializers.py index 6f9d44ed..8f2972d7 100644 --- a/connect/api/v1/project/serializers.py +++ b/connect/api/v1/project/serializers.py @@ -35,6 +35,7 @@ RequestChatsPermission, ChatsAuthorization, ) +from connect.internals.event_driven.producer.rabbitmq_publisher import RabbitmqPublisher logger = logging.getLogger(__name__) @@ -183,6 +184,13 @@ def create(self, validated_data): def update(self, instance, validated_data): name = validated_data.get("name", instance.name) + description = validated_data.get("description", instance.description) + message_body = { + "project_uuid": str(instance.uuid), + "description": description + } + rabbitmq_publisher = RabbitmqPublisher() + rabbitmq_publisher.send_message(message_body, exchange="update-projects.topic", routing_key="") celery_app.send_task( "update_project", args=[instance.uuid, name], diff --git a/connect/api/v2/projects/serializers.py b/connect/api/v2/projects/serializers.py index ae0eb180..23eb5deb 100644 --- a/connect/api/v2/projects/serializers.py +++ b/connect/api/v2/projects/serializers.py @@ -243,9 +243,15 @@ def send_request_flow_product(self, user): def update(self, instance, validated_data): name = validated_data.get("name", instance.name) description = validated_data.get("description", instance.description) + message_body = { + "project_uuid": str(instance.uuid), + "description": description + } + rabbitmq_publisher = RabbitmqPublisher() + rabbitmq_publisher.send_message(message_body, exchange="update-projects.topic", routing_key="") celery_app.send_task( "update_project", - args=[instance.uuid, name, description], + args=[instance.uuid, name], ) updated_instance = super().update(instance, validated_data) if not settings.TESTING: @@ -532,9 +538,15 @@ def update(self, instance, validated_data): # pragma: no cover instance = super().update(instance, validated_data) name = validated_data.get("name", instance.name) description = validated_data.get("description", instance.description) + message_body = { + "project_uuid": str(instance.uuid), + "description": description + } + rabbitmq_publisher = RabbitmqPublisher() + rabbitmq_publisher.send_message(message_body, exchange="update-projects.topic", routing_key="") celery_app.send_task( "update_project", - args=[instance.uuid, name, description], + args=[instance.uuid, name], ) return instance except Exception as error: diff --git a/connect/common/tasks.py b/connect/common/tasks.py index 1a0a7427..a2f9010a 100644 --- a/connect/common/tasks.py +++ b/connect/common/tasks.py @@ -73,7 +73,7 @@ def update_user_permission_organization( retry_kwargs={"max_retries": 5}, retry_backoff=True, ) -def update_project(organization_uuid: str, organization_name: str, organization_description: str = None): +def update_project(organization_uuid: str, organization_name: str): flow_instance = FlowsRESTClient() chats = ChatsRESTClient() chats.update_chats_project(project_uuid=organization_uuid) @@ -81,13 +81,6 @@ def update_project(organization_uuid: str, organization_name: str, organization_ project_uuid=organization_uuid, organization_name=organization_name, ) - if organization_description: - message_body = { - "project_uuid": str(organization_uuid), - "description": organization_description - } - rabbitmq_publisher = RabbitmqPublisher() - rabbitmq_publisher.send_message(message_body, exchange="update-projects.topic", routing_key="") return True