mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 00:06:16 -04:00
Getting NotificationStatus implemented everywhere.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user