From 5ce31c78fdfa4ffbad428f35b17212cb17fd91b0 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Fri, 13 Dec 2024 07:30:41 -0800 Subject: [PATCH] start writing message ids to the notifications table --- app/celery/provider_tasks.py | 4 ++++ app/dao/notifications_dao.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/app/celery/provider_tasks.py b/app/celery/provider_tasks.py index 1e6c7e96f..dd95472c9 100644 --- a/app/celery/provider_tasks.py +++ b/app/celery/provider_tasks.py @@ -14,6 +14,7 @@ from app.config import Config, QueueNames from app.dao import notifications_dao from app.dao.notifications_dao import ( sanitize_successful_notification_by_id, + update_notification_message_id, update_notification_status_by_id, ) from app.delivery import send_to_providers @@ -128,6 +129,9 @@ def deliver_sms(self, notification_id): ) # Code branches off to send_to_providers.py message_id = send_to_providers.send_sms_to_provider(notification) + update_notification_message_id(notification_id, message_id) + + # DEPRECATED # We have to put it in UTC. For other timezones, the delay # will be ignored and it will fire immediately (although this probably only affects developer testing) my_eta = utc_now() + timedelta(seconds=DELIVERY_RECEIPT_DELAY_IN_SECONDS) diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index 8371aaa85..af3f800e7 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -110,6 +110,16 @@ def _update_notification_status( return notification +@autocommit +def update_notification_message_id(notification_id, message_id): + stmt = ( + update(Notification) + .where(Notification.id == notification_id) + .values({"message_id": message_id}) + ) + db.session.execute(stmt) + + @autocommit def update_notification_status_by_id( notification_id, status, sent_by=None, provider_response=None, carrier=None