diff --git a/app/celery/provider_tasks.py b/app/celery/provider_tasks.py index ab8d8435a..a75a68c96 100644 --- a/app/celery/provider_tasks.py +++ b/app/celery/provider_tasks.py @@ -14,7 +14,6 @@ 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 @@ -129,8 +128,6 @@ def deliver_sms(self, notification_id): ) # Code branches off to send_to_providers.py message_id = send_to_providers.send_sms_to_provider(notification) - if message_id is not None: # can be none if technical failure happens - update_notification_message_id(notification_id, message_id) # DEPRECATED # We have to put it in UTC. For other timezones, the delay diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index 066c21387..052242644 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -114,7 +114,7 @@ def update_notification_message_id(notification_id, message_id): stmt = ( update(Notification) .where(Notification.id == notification_id) - .values({"message_id": message_id}) + .values(message_id=message_id) ) db.session.execute(stmt) db.session.commit() diff --git a/app/delivery/send_to_providers.py b/app/delivery/send_to_providers.py index 07763823f..4cc57fa6a 100644 --- a/app/delivery/send_to_providers.py +++ b/app/delivery/send_to_providers.py @@ -16,7 +16,7 @@ from app import ( from app.aws.s3 import get_personalisation_from_s3, get_phone_number_from_s3 from app.celery.test_key_tasks import send_email_response, send_sms_response from app.dao.email_branding_dao import dao_get_email_branding_by_id -from app.dao.notifications_dao import dao_update_notification +from app.dao.notifications_dao import dao_update_notification, update_notification_message_id from app.dao.provider_details_dao import get_provider_details_by_notification_type from app.dao.service_sms_sender_dao import dao_get_sms_senders_by_service_id from app.enums import BrandType, KeyType, NotificationStatus, NotificationType @@ -117,6 +117,7 @@ def send_sms_to_provider(notification): message_id = provider.send_sms(**send_sms_kwargs) current_app.logger.info(f"got message_id {message_id}") + update_notification_message_id(notification.id, message_id) except Exception as e: n = notification msg = f"FAILED send to sms, job_id: {n.job_id} row_number {n.job_row_number} message_id {message_id}"