diff --git a/clevercloud/send_notifications_daily.sh b/clevercloud/send_notifications_daily.sh index 513f6d534..6cc98d4b2 100644 --- a/clevercloud/send_notifications_daily.sh +++ b/clevercloud/send_notifications_daily.sh @@ -15,4 +15,4 @@ fi # $APP_HOME is set by default by clever cloud. cd $APP_HOME -python manage.py send_notifications day +python manage.py send_messages_notifications day diff --git a/clevercloud/send_notifications_regular.sh b/clevercloud/send_notifications_regular.sh index 8d14cfe04..cd806f7e2 100644 --- a/clevercloud/send_notifications_regular.sh +++ b/clevercloud/send_notifications_regular.sh @@ -15,4 +15,4 @@ fi # $APP_HOME is set by default by clever cloud. cd $APP_HOME -python manage.py send_notifications asap +python manage.py send_messages_notifications asap diff --git a/lacommunaute/notification/management/commands/send_notifications.py b/lacommunaute/notification/management/commands/send_messages_notifications.py similarity index 86% rename from lacommunaute/notification/management/commands/send_notifications.py rename to lacommunaute/notification/management/commands/send_messages_notifications.py index add74e3b0..9d54fcece 100644 --- a/lacommunaute/notification/management/commands/send_notifications.py +++ b/lacommunaute/notification/management/commands/send_messages_notifications.py @@ -1,7 +1,7 @@ from django.core.management.base import BaseCommand from lacommunaute.notification.enums import NotificationDelay -from lacommunaute.notification.tasks import send_notifications +from lacommunaute.notification.tasks import send_messages_notifications class Command(BaseCommand): @@ -18,5 +18,5 @@ def add_arguments(self, parser): self.style.ERROR(f"le délai fournit doit être un valeuer de {str(NotificationDelay.values)}") ) - send_notifications(delay) + send_messages_notifications(delay) self.stdout.write(self.style.SUCCESS("That's all, folks!")) diff --git a/lacommunaute/notification/tasks.py b/lacommunaute/notification/tasks.py index 2156138bb..09e90c710 100644 --- a/lacommunaute/notification/tasks.py +++ b/lacommunaute/notification/tasks.py @@ -11,7 +11,7 @@ from lacommunaute.notification.utils import collect_new_users_for_onboarding, get_serialized_messages -def send_notifications(delay: NotificationDelay): +def send_messages_notifications(delay: NotificationDelay): """Notifications are scheduled in the application and then processed later by this task""" def get_grouped_notifications(): @@ -36,7 +36,7 @@ def get_grouped_notifications(): to=[{"email": DEFAULT_FROM_EMAIL}], params=params, bcc=[{"email": recipient}], - kind=EmailSentTrackKind.FIRST_REPLY, + kind=EmailSentTrackKind.FOLLOWING_REPLIES, template_id=SIB_NEW_MESSAGES_TEMPLATE, ) diff --git a/lacommunaute/notification/tests/tests_tasks.py b/lacommunaute/notification/tests/tests_tasks.py index 354ec05e4..89fcaf3cc 100644 --- a/lacommunaute/notification/tests/tests_tasks.py +++ b/lacommunaute/notification/tests/tests_tasks.py @@ -26,7 +26,7 @@ from lacommunaute.notification.models import EmailSentTrack, Notification from lacommunaute.notification.tasks import ( add_user_to_list_when_register, - send_notifications, + send_messages_notifications, send_notifs_on_unanswered_topics, ) from lacommunaute.notification.utils import get_serialized_messages @@ -70,11 +70,11 @@ def get_expected_email_payload(self, notifications): } @respx.mock - def test_send_notifications_asap(self): + def test_send_messages_notifications_asap(self): topic = TopicFactory(with_post=True) notification = NotificationFactory(post=topic.first_post, delay=NotificationDelay.ASAP) - send_notifications(NotificationDelay.ASAP) + send_messages_notifications(NotificationDelay.ASAP) email_sent_track = EmailSentTrack.objects.get() self.assertEqual(email_sent_track.status_code, 200) @@ -84,11 +84,11 @@ def test_send_notifications_asap(self): ) @respx.mock - def test_send_notifications_day(self): + def test_send_messages_notifications_day(self): topic = TopicFactory(with_post=True) notification = NotificationFactory(post=topic.first_post, delay=NotificationDelay.DAY) - send_notifications(NotificationDelay.DAY) + send_messages_notifications(NotificationDelay.DAY) email_sent_track = EmailSentTrack.objects.get() self.assertEqual(email_sent_track.status_code, 200) @@ -98,7 +98,7 @@ def test_send_notifications_day(self): ) @respx.mock - def test_send_notifications_max_messages_preview(self): + def test_send_messages_notifications_max_messages_preview(self): topic = TopicFactory(with_post=True) notif_count_to_generate = NEW_MESSAGES_EMAIL_MAX_PREVIEW + 1 @@ -110,7 +110,7 @@ def test_send_notifications_max_messages_preview(self): post=topic.first_post, ) - send_notifications(NotificationDelay.ASAP) + send_messages_notifications(NotificationDelay.ASAP) email_sent_track = EmailSentTrack.objects.get() self.assertEqual(len(email_sent_track.datas["params"]["messages"]), NEW_MESSAGES_EMAIL_MAX_PREVIEW) @@ -120,18 +120,18 @@ def test_send_notifications_max_messages_preview(self): ) @respx.mock - def test_send_notifications_num_queries(self): + def test_send_messages_notifications_num_queries(self): expected_queries = 1 NotificationFactory(delay=NotificationDelay.ASAP) with self.assertNumQueries(expected_queries): - send_notifications(NotificationDelay.ASAP) + send_messages_notifications(NotificationDelay.ASAP) NotificationFactory.create_batch(10, delay=NotificationDelay.ASAP) with self.assertNumQueries(expected_queries): - send_notifications(NotificationDelay.ASAP) + send_messages_notifications(NotificationDelay.ASAP) class AddUserToListWhenRegister(TestCase):