mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
Small refactor to reduce complexity and satisfy codestyle.
This module could do with a look to check if we can simplify it. But at the moment we just want to record the complaint.
This commit is contained in:
@@ -33,12 +33,8 @@ def process_ses_response(ses_request):
|
||||
|
||||
notification_type = ses_message['notificationType']
|
||||
if notification_type == 'Bounce':
|
||||
current_app.logger.info('SES bounce dict: {}'.format(remove_emails_from_bounce(ses_message['bounce'])))
|
||||
if ses_message['bounce']['bounceType'] == 'Permanent':
|
||||
notification_type = ses_message['bounce']['bounceType'] # permanent or not
|
||||
else:
|
||||
notification_type = 'Temporary'
|
||||
if notification_type == 'Complaint':
|
||||
notification_type = determine_notification_bounce_type(notification_type, ses_message)
|
||||
elif notification_type == 'Complaint':
|
||||
current_app.logger.info("Complaint from SES: \n{}".format(ses_message))
|
||||
return
|
||||
|
||||
@@ -95,6 +91,15 @@ def process_ses_response(ses_request):
|
||||
return error
|
||||
|
||||
|
||||
def determine_notification_bounce_type(notification_type, ses_message):
|
||||
current_app.logger.info('SES bounce dict: {}'.format(remove_emails_from_bounce(ses_message['bounce'])))
|
||||
if ses_message['bounce']['bounceType'] == 'Permanent':
|
||||
notification_type = ses_message['bounce']['bounceType'] # permanent or not
|
||||
else:
|
||||
notification_type = 'Temporary'
|
||||
return notification_type
|
||||
|
||||
|
||||
def remove_emails_from_bounce(bounce_dict):
|
||||
for recip in bounce_dict['bouncedRecipients']:
|
||||
recip.pop('emailAddress')
|
||||
|
||||
Reference in New Issue
Block a user