mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-21 07:51:13 -05:00
keep on flakin the flake world
This commit is contained in:
@@ -30,8 +30,8 @@ def process_ses_results(self, response):
|
|||||||
notification_type = ses_message["notificationType"]
|
notification_type = ses_message["notificationType"]
|
||||||
# TODO remove after smoke testing on prod is implemented
|
# TODO remove after smoke testing on prod is implemented
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
f"Attempting to process SES delivery status message \
|
f"Attempting to process SES delivery status message "
|
||||||
from SNS with type: {notification_type} and body: {ses_message}"
|
f"from SNS with type: {notification_type} and body: {ses_message}"
|
||||||
)
|
)
|
||||||
bounce_message = None
|
bounce_message = None
|
||||||
|
|
||||||
@@ -52,16 +52,16 @@ def process_ses_results(self, response):
|
|||||||
message_time = iso8601.parse_date(ses_message["mail"]["timestamp"]).replace(tzinfo=None)
|
message_time = iso8601.parse_date(ses_message["mail"]["timestamp"]).replace(tzinfo=None)
|
||||||
if datetime.utcnow() - message_time < timedelta(minutes=5):
|
if datetime.utcnow() - message_time < timedelta(minutes=5):
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
f"notification not found for reference: {reference}"
|
f"Notification not found for reference: {reference}"
|
||||||
f"(while attempting update to {notification_status}). "
|
f"(while attempting update to {notification_status}). "
|
||||||
f"Callback may have arrived before notification was"
|
f"Callback may have arrived before notification was"
|
||||||
f"persisted to the DB. Adding task to retry queue"
|
f"persisted to the DB. Adding task to retry queue"
|
||||||
)
|
)
|
||||||
self.retry(queue=QueueNames.RETRY)
|
self.retry(queue=QueueNames.RETRY)
|
||||||
else:
|
else:
|
||||||
current_app.logger.warning(
|
current_app.logger.warning(
|
||||||
f"notification not found for reference: {reference} "
|
f"Notification not found for reference: {reference} "
|
||||||
f"(while attempting update to {notification_status})"
|
f"(while attempting update to {notification_status})"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ from app.inbound_sms.inbound_sms_schemas import (
|
|||||||
)
|
)
|
||||||
from app.schema_validation import validate
|
from app.schema_validation import validate
|
||||||
|
|
||||||
|
|
||||||
inbound_sms = Blueprint(
|
inbound_sms = Blueprint(
|
||||||
'inbound_sms',
|
'inbound_sms',
|
||||||
__name__,
|
__name__,
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ def receive_sns_sms():
|
|||||||
# since this is an issue with our service <-> number mapping, or no inbound_sms service permission
|
# since this is an issue with our service <-> number mapping, or no inbound_sms service permission
|
||||||
# we should still tell SNS that we received it successfully
|
# we should still tell SNS that we received it successfully
|
||||||
current_app.logger.warning(
|
current_app.logger.warning(
|
||||||
f"Mapping between service and inbound number: {inbound_number} is broken, \
|
f"Mapping between service and inbound number: {inbound_number} is broken, "
|
||||||
or service does not have permission to receive inbound sms"
|
f"or service does not have permission to receive inbound sms"
|
||||||
)
|
)
|
||||||
return jsonify(
|
return jsonify(
|
||||||
result="success", message="SMS-SNS callback succeeded"
|
result="success", message="SMS-SNS callback succeeded"
|
||||||
|
|||||||
@@ -58,12 +58,12 @@ def sns_notification_handler(data, headers):
|
|||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
current_app.logger.warning(
|
current_app.logger.warning(
|
||||||
f"Attempt to raise_for_status()SubscriptionConfirmation Type \
|
f"Attempt to raise_for_status()SubscriptionConfirmation Type "
|
||||||
message files for response: {response.text} with error {e}"
|
f"message files for response: {response.text} with error {e}"
|
||||||
)
|
)
|
||||||
raise InvalidRequest(
|
raise InvalidRequest(
|
||||||
"SES-SNS callback failed: attempt to raise_for_status()SubscriptionConfirmation \
|
"SES-SNS callback failed: attempt to raise_for_status()SubscriptionConfirmation "
|
||||||
Type message failed", 400
|
"Type message failed", 400
|
||||||
)
|
)
|
||||||
current_app.logger.info("SES-SNS auto-confirm subscription callback succeeded")
|
current_app.logger.info("SES-SNS auto-confirm subscription callback succeeded")
|
||||||
return message
|
return message
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ def test_ses_callback_should_log_if_notification_is_missing(client, _notify_db,
|
|||||||
assert process_ses_results(ses_notification_callback(reference='ref')) is None
|
assert process_ses_results(ses_notification_callback(reference='ref')) is None
|
||||||
assert mock_retry.call_count == 0
|
assert mock_retry.call_count == 0
|
||||||
mock_logger.assert_called_once_with(
|
mock_logger.assert_called_once_with(
|
||||||
'notification not found for reference: ref (while attempting update to delivered)'
|
'Notification not found for reference: ref (while attempting update to delivered)'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user