mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 08:21:13 -05:00
Return success of the callback is a duplicate or for an id that does not exist
This PR changes the response to POST /notifications/sms/<mmg | firetext> from a 400 response to a 200 response. If we get a callback for a notification more than once or for a notification we log that but we return a 200 success response to the provider. We have found that there is a situation where the send to provider throws a timeout exception but the provider did get the message, but we still send it to them again. In which case they send the message twice, and callback for the message twice. Another case where we may get duplicate callbacks is that the network gave the provider two callbacks meaning they pass those two callbacks onto us. So it is really difficult to know if we sent to the provider twice or just got two callbacks. The test_callback has many changes because I took the opportunity to use the client conftest fixture rather than the notify_api fixture. The only 2 tests really changed are test_mmg_callback_returns_200_when_notification_id_not_found_or_already_updated and test_firetext_callback_returns_200_when_notification_id_not_found_or_already_updated
This commit is contained in:
@@ -58,11 +58,11 @@ def process_sms_client_response(status, reference, client_name):
|
||||
# record stats
|
||||
notification = notifications_dao.update_notification_status_by_id(reference, notification_status)
|
||||
if not notification:
|
||||
status_error = "{} callback failed: notification {} either not found or already updated " \
|
||||
"from sending. Status {}".format(client_name,
|
||||
reference,
|
||||
notification_status_message)
|
||||
return success, status_error
|
||||
current_app.logger.info("{} callback failed: notification {} either not found or already updated "
|
||||
"from sending. Status {}".format(client_name,
|
||||
reference,
|
||||
notification_status_message))
|
||||
return success, errors
|
||||
|
||||
if not notification_success:
|
||||
current_app.logger.info(
|
||||
|
||||
@@ -149,10 +149,7 @@ def process_firetext_response():
|
||||
if errors:
|
||||
raise InvalidRequest(errors, status_code=400)
|
||||
|
||||
response_code = request.form.get('code')
|
||||
status = request.form.get('status')
|
||||
current_app.logger.info('Firetext status: {}, extended error code: {}'.format(status, response_code))
|
||||
|
||||
success, errors = process_sms_client_response(status=status,
|
||||
reference=request.form.get('reference'),
|
||||
client_name=client_name)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user