Getting NotificationStatus implemented everywhere.

Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
Cliff Hill
2024-01-18 10:28:15 -05:00
parent a177042e77
commit 69a9accfca
16 changed files with 179 additions and 285 deletions

View File

@@ -15,13 +15,8 @@ from app.dao.notifications_dao import (
update_notification_status_by_id,
)
from app.delivery import send_to_providers
from app.enum import NotificationStatus
from app.exceptions import NotificationTechnicalFailureException
from app.models import (
NOTIFICATION_DELIVERED,
NOTIFICATION_FAILED,
NOTIFICATION_TECHNICAL_FAILURE,
NOTIFICATION_TEMPORARY_FAILURE,
)
# This is the amount of time to wait after sending an sms message before we check the aws logs and look for delivery
# receipts
@@ -67,12 +62,12 @@ def check_sms_delivery_receipt(self, message_id, notification_id, sent_at):
raise self.retry(exc=ntfe)
if status == "success":
status = NOTIFICATION_DELIVERED
status = NotificationStatus.DELIVERED
elif status == "failure":
status = NOTIFICATION_FAILED
status = NotificationStatus.FAILED
# if status is not success or failure the client raised an exception and this method will retry
if status == NOTIFICATION_DELIVERED:
if status == NotificationStatus.DELIVERED:
sanitize_successful_notification_by_id(
notification_id, carrier=carrier, provider_response=provider_response
)
@@ -126,7 +121,7 @@ def deliver_sms(self, notification_id):
)
except Exception as e:
update_notification_status_by_id(
notification_id, NOTIFICATION_TEMPORARY_FAILURE
notification_id, NotificationStatus.TEMPORARY_FAILURE,
)
if isinstance(e, SmsClientResponseException):
current_app.logger.warning(
@@ -151,7 +146,7 @@ def deliver_sms(self, notification_id):
)
)
update_notification_status_by_id(
notification_id, NOTIFICATION_TECHNICAL_FAILURE
notification_id, NotificationStatus.TECHNICAL_FAILURE,
)
raise NotificationTechnicalFailureException(message)
@@ -194,6 +189,6 @@ def deliver_email(self, notification_id):
)
)
update_notification_status_by_id(
notification_id, NOTIFICATION_TECHNICAL_FAILURE
notification_id, NotificationStatus.TECHNICAL_FAILURE,
)
raise NotificationTechnicalFailureException(message)