Skip to content

Commit

Permalink
Change recent activities to EDA
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslinhares committed Mar 6, 2024
1 parent 952e01a commit 249d118
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 61 deletions.
17 changes: 10 additions & 7 deletions weni/activities/signals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import celery
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
Expand All @@ -7,21 +6,23 @@
from temba.flows.models import Flow
from temba.triggers.models import Trigger
from temba.campaigns.models import Campaign
from temba.event_driven.publisher.rabbitmq_publisher import RabbitmqPublisher


def create_recent_activity(instance: models.Model, created: bool):
if instance.is_active:
action = "CREATE" if created else "UPDATE"

celery.execute.send_task(
"create_recent_activity",
kwargs=dict(
rabbitmq_publisher = RabbitmqPublisher()
rabbitmq_publisher.send_message(
body=dict(
action=action,
entity=instance.__class__.__name__.upper(),
entity_name=getattr(instance, "name", None),
user=instance.modified_by.email,
flow_organization=str(instance.org.uuid),
),
exchange="recent-activities.topic",
routing_key="",
)


Expand All @@ -31,7 +32,7 @@ def channel_recent_activity_signal(sender, instance: Channel, created: bool, **k
if instance.channel_type not in ["WA", "WAC"] or update_fields != frozenset(
{
"config",
}
},
):
create_recent_activity(instance, created)

Expand Down Expand Up @@ -61,5 +62,7 @@ def trigger_recent_activity_signal(sender, instance: Trigger, created: bool, **k


@receiver(post_save, sender=Campaign)
def campaign_recent_activity_signal(sender, instance: Campaign, created: bool, **kwargs):
def campaign_recent_activity_signal(
sender, instance: Campaign, created: bool, **kwargs
):
create_recent_activity(instance, created)
9 changes: 0 additions & 9 deletions weni/activities/tasks.py

This file was deleted.

3 changes: 0 additions & 3 deletions weni/internal/clients/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from weni.internal.clients.connect import ConnectInternalClient # noqa: F401

__all__ = "ConnectInternalClient"
42 changes: 0 additions & 42 deletions weni/internal/clients/connect.py

This file was deleted.

0 comments on commit 249d118

Please sign in to comment.