mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
Remove email from the log message
This commit is contained in:
@@ -35,6 +35,7 @@ def process_ses_response(ses_request):
|
|||||||
if notification_type == 'Bounce':
|
if notification_type == 'Bounce':
|
||||||
notification_type = determine_notification_bounce_type(notification_type, ses_message)
|
notification_type = determine_notification_bounce_type(notification_type, ses_message)
|
||||||
elif notification_type == 'Complaint':
|
elif notification_type == 'Complaint':
|
||||||
|
remove_emails_from_complaint(ses_message)
|
||||||
current_app.logger.info("Complaint from SES: \n{}".format(ses_message))
|
current_app.logger.info("Complaint from SES: \n{}".format(ses_message))
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -105,6 +106,10 @@ def remove_emails_from_bounce(bounce_dict):
|
|||||||
recip.pop('emailAddress')
|
recip.pop('emailAddress')
|
||||||
|
|
||||||
|
|
||||||
|
def remove_emails_from_complaint(complaint_dict):
|
||||||
|
complaint_dict['complaint'].pop('complainedRecipients')
|
||||||
|
|
||||||
|
|
||||||
def _check_and_queue_callback_task(notification):
|
def _check_and_queue_callback_task(notification):
|
||||||
# queue callback task only if the service_callback_api exists
|
# queue callback task only if the service_callback_api exists
|
||||||
service_callback_api = get_service_callback_api_for_service(service_id=notification.service_id)
|
service_callback_api = get_service_callback_api_for_service(service_id=notification.service_id)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import json
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from app.celery.process_ses_receipts_tasks import process_ses_results
|
from app.celery.process_ses_receipts_tasks import process_ses_results
|
||||||
|
from app.notifications.notifications_ses_callback import remove_emails_from_complaint
|
||||||
|
|
||||||
from tests.app.db import create_notification
|
from tests.app.db import create_notification
|
||||||
|
|
||||||
@@ -39,6 +40,13 @@ def test_process_ses_results_in_complaint(notify_db, mocker):
|
|||||||
assert mocked.call_count == 0
|
assert mocked.call_count == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_remove_emails_from_complaint():
|
||||||
|
test_message = ses_complaint_callback()
|
||||||
|
test_json = json.loads(json.loads(test_message)['Message'])
|
||||||
|
remove_emails_from_complaint(test_json)
|
||||||
|
assert "recipient1@example.com" not in test_json
|
||||||
|
|
||||||
|
|
||||||
def ses_notification_callback():
|
def ses_notification_callback():
|
||||||
return '{\n "Type" : "Notification",\n "MessageId" : "ref1",' \
|
return '{\n "Type" : "Notification",\n "MessageId" : "ref1",' \
|
||||||
'\n "TopicArn" : "arn:aws:sns:eu-west-1:123456789012:testing",' \
|
'\n "TopicArn" : "arn:aws:sns:eu-west-1:123456789012:testing",' \
|
||||||
|
|||||||
Reference in New Issue
Block a user