mirror of
https://github.com/simple-login/app.git
synced 2024-11-13 07:31:12 +01:00
special handling for case when alias can't be disabled
This commit is contained in:
parent
29b6b52a62
commit
9cf807f7bd
1 changed files with 11 additions and 11 deletions
|
@ -976,8 +976,11 @@ def handle_bounce(contact: Contact, alias: Alias, msg: Message, user: User):
|
|||
)
|
||||
|
||||
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 if this is the first bounced email
|
||||
if nb_bounced == 1:
|
||||
if nb_bounced == 1 or (nb_bounced >= 2 and alias.cannot_be_disabled):
|
||||
LOG.d(
|
||||
"Inform user %s about bounced email sent by %s to alias %s",
|
||||
user,
|
||||
|
@ -1010,16 +1013,13 @@ def handle_bounce(contact: Contact, alias: Alias, msg: Message, user: User):
|
|||
)
|
||||
# disable the alias the second time email is bounced
|
||||
elif nb_bounced >= 2:
|
||||
if alias.cannot_be_disabled:
|
||||
LOG.warning("%s cannot be disabled", alias)
|
||||
else:
|
||||
LOG.d(
|
||||
"Bounce happens again with alias %s from %s. Disable alias now ",
|
||||
alias,
|
||||
contact.website_email,
|
||||
)
|
||||
alias.enabled = False
|
||||
db.session.commit()
|
||||
LOG.d(
|
||||
"Bounce happens again with alias %s from %s. Disable alias now ",
|
||||
alias,
|
||||
contact.website_email,
|
||||
)
|
||||
alias.enabled = False
|
||||
db.session.commit()
|
||||
|
||||
send_email_with_rate_control(
|
||||
user,
|
||||
|
|
Loading…
Reference in a new issue