mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 21:48:49 -04:00
Getting NotificationStatus implemented everywhere.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
@@ -20,7 +20,8 @@ from app.dao.service_callback_api_dao import (
|
||||
get_service_complaint_callback_api_for_service,
|
||||
get_service_delivery_status_callback_api_for_service,
|
||||
)
|
||||
from app.models import NOTIFICATION_PENDING, NOTIFICATION_SENDING, Complaint
|
||||
from app.enums import NotificationStatus
|
||||
from app.models import Complaint
|
||||
|
||||
|
||||
@notify_celery.task(
|
||||
@@ -76,7 +77,7 @@ def process_ses_results(self, response):
|
||||
f"SES bounce for notification ID {notification.id}: {bounce_message}"
|
||||
)
|
||||
|
||||
if notification.status not in {NOTIFICATION_SENDING, NOTIFICATION_PENDING}:
|
||||
if notification.status not in {NotificationStatus.SENDING, NotificationStatus.PENDING}:
|
||||
notifications_dao._duplicate_update_warning(
|
||||
notification, notification_status
|
||||
)
|
||||
|
||||
@@ -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