diff --git a/app/celery/tasks.py b/app/celery/tasks.py index 0564ce2d83..6e462c4e70 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -228,12 +228,14 @@ def save_sms( if is_feature_enabled(FeatureFlag.SMS_SENDER_RATE_LIMIT_ENABLED) and sms_sender and sms_sender.rate_limit: provider_tasks.deliver_sms_with_rate_limiting.apply_async( - [str(saved_notification.id)], + args=[], + kwargs={'notification_id': str(saved_notification.id)}, queue=QueueNames.SEND_SMS if not service.research_mode else QueueNames.NOTIFY, ) else: provider_tasks.deliver_sms.apply_async( - [str(saved_notification.id)], + args=[], + kwargs={'notification_id': str(saved_notification.id)}, queue=QueueNames.SEND_SMS if not service.research_mode else QueueNames.NOTIFY, ) diff --git a/app/clients/email/aws_ses.py b/app/clients/email/aws_ses.py index 42ff56c351..866e460368 100644 --- a/app/clients/email/aws_ses.py +++ b/app/clients/email/aws_ses.py @@ -98,6 +98,7 @@ def send_email( # noqa: C901 html_body='', reply_to_address=None, attachments=None, + notification_id=None, ): def create_mime_base( attachments, diff --git a/app/notifications/process_notifications.py b/app/notifications/process_notifications.py index c04ca09c58..5f765f7595 100644 --- a/app/notifications/process_notifications.py +++ b/app/notifications/process_notifications.py @@ -170,12 +170,18 @@ def send_notification_to_queue( if communication_item_id is not None: if recipient_id_type != IdentifierType.VA_PROFILE_ID.value: - tasks.append(lookup_va_profile_id.si(notification.id).set(queue=QueueNames.LOOKUP_VA_PROFILE_ID)) + tasks.append( + lookup_va_profile_id.si(notification_id=str(notification.id)).set( + queue=QueueNames.LOOKUP_VA_PROFILE_ID + ) + ) # Including sms_sender_id is necessary so the correct sender can be chosen. # https://docs.celeryq.dev/en/v4.4.7/userguide/canvas.html#immutability - deliver_task, queue = _get_delivery_task(notification, research_mode, queue, sms_sender_id) - tasks.append(deliver_task.si(str(notification.id), sms_sender_id).set(queue=queue)) + deliver_task, queue = _get_delivery_task( + notification, research_mode, queue, sms_sender_id, notification_id=str(notification.id) + ) + tasks.append(deliver_task.si(notification_id=str(notification.id), sms_sender_id=sms_sender_id).set(queue=queue)) try: # This executes the task list. Each task calls a function that makes a request to @@ -199,6 +205,7 @@ def _get_delivery_task( research_mode=False, queue=None, sms_sender_id=None, + notification_id=None, ): """ The return value "deliver_task" is a function decorated to be a Celery task. @@ -261,15 +268,15 @@ def send_to_queue_for_recipient_info_based_on_recipient_identifier( else: tasks = [ - lookup_va_profile_id.si(notification.id).set(queue=QueueNames.LOOKUP_VA_PROFILE_ID), + lookup_va_profile_id.si(notification_id=notification.id).set(queue=QueueNames.LOOKUP_VA_PROFILE_ID), send_va_onsite_notification_task.s(str(notification.template.id), onsite_enabled).set( queue=QueueNames.NOTIFY ), ] tasks.append(lookup_contact_info.si(notification.id).set(queue=QueueNames.LOOKUP_CONTACT_INFO)) - deliver_task, deliver_queue = _get_delivery_task(notification) - tasks.append(deliver_task.si(notification.id).set(queue=deliver_queue)) + deliver_task, deliver_queue = _get_delivery_task(notification, notification_id=notification.id) + tasks.append(deliver_task.si(notification.id, notification_id=notification.id).set(queue=deliver_queue)) try: # This executes the task list. Each task calls a function that makes a request to