diff --git a/app/email_utils.py b/app/email_utils.py index 03cdcad2..24a890d8 100644 --- a/app/email_utils.py +++ b/app/email_utils.py @@ -922,6 +922,11 @@ def normalize_reply_email(reply_email: str) -> str: def should_disable(alias: Alias) -> bool: """Disable an alias if it has more than 5 bounces in the last 24h""" + # Bypass the bounce rule + if alias.cannot_be_disabled: + LOG.warning("%s cannot be disabled", alias) + return False + yesterday = arrow.now().shift(days=-1) nb_bounced_last_24h = ( db.session.query(EmailLog) diff --git a/email_handler.py b/email_handler.py index cbe0a8e5..52438fb9 100644 --- a/email_handler.py +++ b/email_handler.py @@ -1325,10 +1325,6 @@ def handle_bounce_forward_phase(msg: Message, email_log: EmailLog): refused_email_url = f"{URL}/dashboard/refused_email?highlight_id={email_log.id}" - nb_bounced = EmailLog.filter_by(contact_id=contact.id, bounced=True).count() - if nb_bounced >= 2 and alias.cannot_be_disabled: - LOG.warning("%s cannot be disabled", alias) - # inform user of this bounce if not should_disable(alias): LOG.d(