FEATURE: automatic PM when a user's email is revoked

This commit is contained in:
Régis Hanol 2018-08-03 16:39:22 +02:00
parent 6ede7c4623
commit ac2513b0f2
3 changed files with 24 additions and 1 deletions

View File

@ -2593,6 +2593,15 @@ en:
Please make sure you have properly configured the POP credentials in [the site settings](%{base_url}/admin/site_settings/category/email).
If there is a web UI for the POP email account, you may need to log in on the web and check your settings there.
email_revoked:
title: "Email Revoked"
subject_template: "[%{email_prefix}] Is your email address correct?"
text_body_template: |
We're sorry, but we're having trouble reaching you via email.
Can you make sure [your email address](%{base_url}/my/preferences/email) is a valid and working email address?
too_many_spam_flags:
title: "Too Many Spam Flags"
subject_template: "New account on hold"

View File

@ -232,9 +232,12 @@ module Email
reason = I18n.t("user.deactivated", email: user.email)
StaffActionLogger.new(Discourse.system_user).log_user_deactivate(user, reason)
elsif range === SiteSetting.bounce_score_threshold
# NOTE: we check bounce_score before sending emails, nothing to do here other than log it happened.
# NOTE: we check bounce_score before sending emails
# So log we revoked the email...
reason = I18n.t("user.email.revoked", email: user.email, date: user.user_stat.reset_bounce_score_after)
StaffActionLogger.new(Discourse.system_user).log_revoke_email(user, reason)
# ... and PM the user
SystemMessage.create_from_system_user(user, :email_revoked)
end
end
end

View File

@ -129,6 +129,17 @@ describe Email::Receiver do
expect(email_log_2.bounced).to eq(true)
end
it "sends a system message once they reach the 'bounce_score_threshold'" do
expect(user.active).to eq(true)
user.user_stat.bounce_score = SiteSetting.bounce_score_threshold - 1
user.user_stat.save!
SystemMessage.expects(:create_from_system_user).with(user, :email_revoked)
expect { process(:hard_bounce_via_verp) }.to raise_error(Email::Receiver::BouncedEmailError)
end
it "automatically deactive users once they reach the 'bounce_score_threshold_deactivate' threshold" do
expect(user.active).to eq(true)