update research mode email callbacks to add process-ses-response task to queue

this involved:
* moving that task to callback_tasks to prevent circular imports
* updating the dummy research mode callbacks (with actual SNS messages from the
  ses simulator emails)
* refactoring tests
This commit is contained in:
Leo Hemsted
2017-11-17 13:41:45 +00:00
parent 0e477b7715
commit d2154451e5
11 changed files with 158 additions and 106 deletions

View File

@@ -28,7 +28,7 @@ def process_ses_response(ses_request):
notification_type = ses_message['notificationType']
if notification_type == 'Bounce':
current_app.logger.info('SES bounce dict: {}'.format(ses_message['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:
@@ -85,3 +85,8 @@ def process_ses_response(ses_request):
except ValueError:
error = "{} callback failed: invalid json".format(client_name)
return error
def remove_emails_from_bounce(bounce_dict):
for recip in bounce_dict['bouncedRecipients']:
recip.pop('emailAddress')