mirror of
https://github.com/simple-login/app.git
synced 2024-09-20 15:05:59 +08:00
lessen alias automatic disable check
This commit is contained in:
parent
99dc45e09a
commit
350f498b94
|
@ -1143,11 +1143,11 @@ def should_disable(alias: Alias) -> (bool, str):
|
|||
)
|
||||
# if more than 12 bounces in 24h -> disable alias
|
||||
if nb_bounced_last_24h > 12:
|
||||
return True, "more than 12 bounces in the last 24h"
|
||||
return True, "+12 bounces in the last 24h"
|
||||
|
||||
# if more than 5 bounces but has bounces last week -> disable alias
|
||||
# if more than 5 bounces but has +10 bounces last week -> disable alias
|
||||
elif nb_bounced_last_24h > 5:
|
||||
one_week_ago = arrow.now().shift(days=-8)
|
||||
one_week_ago = arrow.now().shift(days=-7)
|
||||
nb_bounced_7d_1d = (
|
||||
Session.query(EmailLog)
|
||||
.filter(
|
||||
|
@ -1159,10 +1159,10 @@ def should_disable(alias: Alias) -> (bool, str):
|
|||
.filter(EmailLog.alias_id == alias.id)
|
||||
.count()
|
||||
)
|
||||
if nb_bounced_7d_1d > 1:
|
||||
if nb_bounced_7d_1d > 10:
|
||||
return (
|
||||
True,
|
||||
"more than 5 bounces in the last 24h and more than 1 bounces in the last 7 days",
|
||||
"+5 bounces in the last 24h and +10 bounces in the last 7 days",
|
||||
)
|
||||
else:
|
||||
# alias level
|
||||
|
|
|
@ -1395,7 +1395,6 @@ def handle_bounce_forward_phase(msg: Message, email_log: EmailLog):
|
|||
|
||||
refused_email_url = f"{URL}/dashboard/refused_email?highlight_id={email_log.id}"
|
||||
|
||||
# inform user of this bounce
|
||||
alias_will_be_disabled, reason = should_disable(alias)
|
||||
if alias_will_be_disabled:
|
||||
LOG.w(
|
||||
|
|
|
@ -721,8 +721,8 @@ def test_should_disable_bounce_consecutive_days(flask_client):
|
|||
)
|
||||
assert not should_disable(alias)[0]
|
||||
|
||||
# create 2 bounces in the last 7 days: alias should be disabled
|
||||
for _ in range(2):
|
||||
# create +10 bounces in the last 7 days: alias should be disabled
|
||||
for _ in range(11):
|
||||
EmailLog.create(
|
||||
user_id=user.id,
|
||||
contact_id=contact.id,
|
||||
|
|
Loading…
Reference in a new issue