FEATURE: erode bounce score every time an email is sent
Introduces a hidden setting (default is 0.1) that erodes bounce score every time we send an email. This means that erratic failures are less painful cause system auto corrects
This commit is contained in:
parent
e25a6e085e
commit
740308675b
|
@ -45,6 +45,12 @@ module Jobs
|
|||
|
||||
if message
|
||||
Email::Sender.new(message, type, user).send
|
||||
if (b = user.user_stat.bounce_score) > SiteSetting.bounce_score_erode_on_send
|
||||
# erode bounce score each time we send an email
|
||||
# this means that we are punished a lot less for bounces
|
||||
# and we can recover more quickly
|
||||
user.user_stat.update(bounce_score: b - SiteSetting.bounce_score_erode_on_send)
|
||||
end
|
||||
else
|
||||
skip_reason_type
|
||||
end
|
||||
|
|
|
@ -841,6 +841,9 @@ email:
|
|||
default: 4
|
||||
min: 1
|
||||
bounce_score_threshold_deactivate: 30
|
||||
bounce_score_erode_on_send:
|
||||
default: 0.1
|
||||
hidden: true
|
||||
soft_bounce_score:
|
||||
default: 1
|
||||
min: 1
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class ChangeBounceScoreToFloat < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
change_column :user_stats, :bounce_score, :float
|
||||
end
|
||||
end
|
|
@ -291,6 +291,34 @@ describe Jobs::UserEmail do
|
|||
end
|
||||
end
|
||||
|
||||
it "erodes bounce score each time an email is sent" do
|
||||
SiteSetting.bounce_score_erode_on_send = 0.2
|
||||
|
||||
user.user_stat.update(bounce_score: 2.7)
|
||||
|
||||
Jobs::UserEmail.new.execute(
|
||||
type: :user_mentioned,
|
||||
user_id: user.id,
|
||||
notification_id: notification.id,
|
||||
post_id: post.id
|
||||
)
|
||||
|
||||
user.user_stat.reload
|
||||
expect(user.user_stat.bounce_score).to eq(2.5)
|
||||
|
||||
user.user_stat.update(bounce_score: 0)
|
||||
|
||||
Jobs::UserEmail.new.execute(
|
||||
type: :user_mentioned,
|
||||
user_id: user.id,
|
||||
notification_id: notification.id,
|
||||
post_id: post.id
|
||||
)
|
||||
|
||||
user.user_stat.reload
|
||||
expect(user.user_stat.bounce_score).to eq(0)
|
||||
end
|
||||
|
||||
it "does not send notification if bounce threshold is reached" do
|
||||
user.user_stat.update(bounce_score: SiteSetting.bounce_score_threshold)
|
||||
|
||||
|
|
Loading…
Reference in New Issue