Skip to content

Commit

Permalink
feat: don't reply to no-reply senders with SES inbound (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti authored Mar 1, 2021
1 parent a6c08a9 commit c1c1aa7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions aws/common/lambdas/ses_receiving_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def notify_service_in_recipients(recipients):
return GC_NOTIFY_SERVICE_EMAIL in recipients


def no_reply_in_recipients(recipients):
return any([email.startswith('no-reply@') for email in recipients])


def lambda_handler(event, context):
sqs = boto3.resource('sqs', region_name=SQS_REGION)
queue = sqs.get_queue_by_name(QueueName=f"{CELERY_QUEUE_PREFIX}{CELERY_QUEUE}")
Expand Down Expand Up @@ -125,6 +129,10 @@ def lambda_handler(event, context):
print("Not replying because recipients contain the GC Notify service. Stopping.")
return {'statusCode': 200}

if no_reply_in_recipients(recipients):
print("Not replying because recipients contain a no-reply email address. Stopping.")
return {'statusCode': 200}

print(
f"Received email addressed to {recipients} from {sender} with subject {subject} in reply to {messageId}"
)
Expand Down

0 comments on commit c1c1aa7

Please sign in to comment.