FIX: always send critical emails even when bounce score threshold has been reached
This commit is contained in:
parent
090236b15b
commit
cf8bc4483f
|
@ -56,7 +56,7 @@ module Jobs
|
|||
quoted
|
||||
}
|
||||
|
||||
CRITICAL_EMAIL_TYPES = Set.new %i{
|
||||
CRITICAL_EMAIL_TYPES ||= Set.new %w{
|
||||
account_created
|
||||
admin_login
|
||||
confirm_new_email
|
||||
|
@ -135,7 +135,7 @@ module Jobs
|
|||
return skip_message(I18n.t('email_log.exceeded_emails_limit'))
|
||||
end
|
||||
|
||||
if !CRITICAL_EMAIL_TYPES.include?(type) && user.user_stat.bounce_score >= SiteSetting.bounce_score_threshold
|
||||
if !CRITICAL_EMAIL_TYPES.include?(type.to_s) && user.user_stat.bounce_score >= SiteSetting.bounce_score_threshold
|
||||
return skip_message(I18n.t('email_log.exceeded_bounces_limit'))
|
||||
end
|
||||
|
||||
|
|
|
@ -35,6 +35,20 @@ describe Jobs::UserEmail do
|
|||
Jobs::UserEmail.new.execute(type: :digest, user_id: staged.id)
|
||||
end
|
||||
|
||||
context "bounce score" do
|
||||
|
||||
it "always sends critical emails when bounce score threshold has been reached" do
|
||||
email_token = Fabricate(:email_token)
|
||||
user.user_stat.update(bounce_score: SiteSetting.bounce_score_threshold + 1)
|
||||
|
||||
Jobs::CriticalUserEmail.new.execute(type: "signup", user_id: user.id, email_token: email_token.token)
|
||||
|
||||
email_log = EmailLog.where(user_id: user.id).last
|
||||
expect(email_log.email_type).to eq("signup")
|
||||
expect(email_log.skipped).to eq(false)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'to_address' do
|
||||
it 'overwrites a to_address when present' do
|
||||
|
|
Loading…
Reference in New Issue