A platform for community discussion. Free, open, simple.
FIX: Queue incoming email for review when `Authentication-Results` can't be evaluated
Régis Hanold90d67df5cdd
diff --git a/lib/email/receiver.rb b/lib/email/receiver.rbindex 285330d8280..57319cefa85 100644--- a/lib/email/receiver.rb+++ b/lib/email/receiver.rb@@ -423,6 +423,10 @@ module Emaildef auth_res_action@auth_res_action ||= AuthenticationResults.new(@mail.header[:authentication_results]).action+ rescue StandardError => e+ # fail closed without losing the post: queue it for review+ Discourse.warn_exception(e, message: "Failed to evaluate Authentication-Results")+ @auth_res_action = :enqueueenddef select_bodydiff --git a/spec/lib/email/receiver_spec.rb b/spec/lib/email/receiver_spec.rbindex bd257f48415..f0cd64b6ba5 100644--- a/spec/lib/email/receiver_spec.rb+++ b/spec/lib/email/receiver_spec.rb@@ -902,6 +902,19 @@ RSpec.describe Email::Receiver doexpect(user.reload.silenced?).to be(false)end+ it "enqueues the post when evaluating the Authentication-Results header fails" do+ Email::AuthenticationResults.any_instance.stubs(:action).raises(StandardError)+ Discourse.expects(:warn_exception).once++ Fabricate(+ :user,+ email: "[email protected]",+ trust_level: TrustLevel[2],+ refresh_auto_groups: true,+ )+ expect { process(:existing_user) }.to change { ReviewableQueuedPost.count }.by(1)+ end+it "adds the 'elided' part of the original message when always_show_trimmed_content is enabled" doSiteSetting.always_show_trimmed_content = true