mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
canada UK ses callbacks monster mash
This commit is contained in:
@@ -87,16 +87,21 @@ def country_records_delivery(phone_prefix):
|
||||
dlr = INTERNATIONAL_BILLING_RATES[phone_prefix]['attributes']['dlr']
|
||||
return dlr and dlr.lower() == 'yes'
|
||||
|
||||
def _decide_permanent_temporary_failure(current_status, status):
|
||||
# If we go from pending to delivered we need to set failure type as temporary-failure
|
||||
if current_status == NOTIFICATION_PENDING and status == NOTIFICATION_PERMANENT_FAILURE:
|
||||
status = NOTIFICATION_TEMPORARY_FAILURE
|
||||
return status
|
||||
|
||||
def _update_notification_status(notification, status, detailed_status_code=None):
|
||||
# status = _decide_permanent_temporary_failure(
|
||||
# status=status, notification=notification, detailed_status_code=detailed_status_code
|
||||
# )
|
||||
# notification.status = status
|
||||
# dao_update_notification(notification)
|
||||
|
||||
def _update_notification_status(notification, status, provider_response=None):
|
||||
status = _decide_permanent_temporary_failure(current_status=notification.status, status=status)
|
||||
notification.status = status
|
||||
if provider_response:
|
||||
notification.provider_response = provider_response
|
||||
dao_update_notification(notification)
|
||||
return notification
|
||||
|
||||
|
||||
@autocommit
|
||||
def update_notification_status_by_id(notification_id, status, sent_by=None, detailed_status_code=None):
|
||||
notification = Notification.query.with_for_update().filter(Notification.id == notification_id).first()
|
||||
@@ -599,6 +604,14 @@ def dao_get_notification_or_history_by_reference(reference):
|
||||
NotificationHistory.reference == reference
|
||||
).one()
|
||||
|
||||
def dao_get_notification_history_by_reference(reference):
|
||||
try:
|
||||
# This try except is necessary because in test keys and research mode does not create notification history.
|
||||
# Otherwise we could just search for the NotificationHistory object
|
||||
return Notification.query.filter(Notification.reference == reference).one()
|
||||
except NoResultFound:
|
||||
return NotificationHistory.query.filter(NotificationHistory.reference == reference).one()
|
||||
|
||||
|
||||
def dao_get_notifications_processing_time_stats(start_date, end_date):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user