From 0ec4a3971c83671b5f08e801c18bb0cca3e9f444 Mon Sep 17 00:00:00 2001 From: Son Date: Wed, 13 Oct 2021 10:27:54 +0200 Subject: [PATCH] Revert "sleep for 60s when rate limit is hit for the first time" This reverts commit 2524c8ab98c660e2654652a6ad67e2b76333cb86. --- email_handler.py | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/email_handler.py b/email_handler.py index 1f6dda19..fea0769f 100644 --- a/email_handler.py +++ b/email_handler.py @@ -1858,37 +1858,24 @@ async def handle(envelope: Envelope) -> str: return status.E523 if rate_limited(mail_from, rcpt_tos): - LOG.w( - "Rate Limiting applied for mail_from:%s rcpt_tos:%s, retry in 60s", - mail_from, - rcpt_tos, - ) - # slow down the rate a bit - await asyncio.sleep(60) + LOG.w("Rate Limiting applied for mail_from:%s rcpt_tos:%s", mail_from, rcpt_tos) - # rate limit is still applied - if rate_limited(mail_from, rcpt_tos): - LOG.w( - "Rate Limiting (no retry) applied for mail_from:%s rcpt_tos:%s", - mail_from, - rcpt_tos, - ) - # add more logging info. TODO: remove - if len(rcpt_tos) == 1: - alias = Alias.get_by(email=rcpt_tos[0]) - if alias: - LOG.w( - "total number email log on %s, %s is %s, %s", - alias, - alias.user, - EmailLog.filter(EmailLog.alias_id == alias.id).count(), - EmailLog.filter(EmailLog.user_id == alias.user_id).count(), - ) + # add more logging info. TODO: remove + if len(rcpt_tos) == 1: + alias = Alias.get_by(email=rcpt_tos[0]) + if alias: + LOG.w( + "total number email log on %s, %s is %s, %s", + alias, + alias.user, + EmailLog.filter(EmailLog.alias_id == alias.id).count(), + EmailLog.filter(EmailLog.user_id == alias.user_id).count(), + ) - if should_ignore_bounce(envelope.mail_from): - return status.E207 - else: - return status.E522 + if should_ignore_bounce(envelope.mail_from): + return status.E207 + else: + return status.E522 # Handle "out of office" auto notice. An automatic response is sent for every forwarded email # todo: remove logging