start writing message ids to the notifications table

This commit is contained in:
Kenneth Kehl
2024-12-13 07:30:41 -08:00
parent b993ed9fe0
commit 5ce31c78fd
2 changed files with 14 additions and 0 deletions

View File

@@ -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)

View File

@@ -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