Revert "sleep for 60s when rate limit is hit for the first time"
This reverts commit 2524c8ab98
.
This commit is contained in:
parent
becf789d5e
commit
0ec4a3971c
|
@ -1858,37 +1858,24 @@ async def handle(envelope: Envelope) -> str:
|
||||||
return status.E523
|
return status.E523
|
||||||
|
|
||||||
if rate_limited(mail_from, rcpt_tos):
|
if rate_limited(mail_from, rcpt_tos):
|
||||||
LOG.w(
|
LOG.w("Rate Limiting applied for mail_from:%s rcpt_tos:%s", mail_from, rcpt_tos)
|
||||||
"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)
|
|
||||||
|
|
||||||
# rate limit is still applied
|
# add more logging info. TODO: remove
|
||||||
if rate_limited(mail_from, rcpt_tos):
|
if len(rcpt_tos) == 1:
|
||||||
LOG.w(
|
alias = Alias.get_by(email=rcpt_tos[0])
|
||||||
"Rate Limiting (no retry) applied for mail_from:%s rcpt_tos:%s",
|
if alias:
|
||||||
mail_from,
|
LOG.w(
|
||||||
rcpt_tos,
|
"total number email log on %s, %s is %s, %s",
|
||||||
)
|
alias,
|
||||||
# add more logging info. TODO: remove
|
alias.user,
|
||||||
if len(rcpt_tos) == 1:
|
EmailLog.filter(EmailLog.alias_id == alias.id).count(),
|
||||||
alias = Alias.get_by(email=rcpt_tos[0])
|
EmailLog.filter(EmailLog.user_id == alias.user_id).count(),
|
||||||
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):
|
if should_ignore_bounce(envelope.mail_from):
|
||||||
return status.E207
|
return status.E207
|
||||||
else:
|
else:
|
||||||
return status.E522
|
return status.E522
|
||||||
|
|
||||||
# Handle "out of office" auto notice. An automatic response is sent for every forwarded email
|
# Handle "out of office" auto notice. An automatic response is sent for every forwarded email
|
||||||
# todo: remove logging
|
# todo: remove logging
|
||||||
|
|
Loading…
Reference in New Issue