mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:42:02 +08:00
FIX: email receiver should ignore x-auto-response-suppress
This header is used by Microsoft Exchange to indicate when certain types of autoresponses should not be generated for an email. It triggers our "is this mail autogenerated?" detection, but should not be used for this purpose.
This commit is contained in:
parent
6ce1fbc479
commit
076def505e
|
@ -383,7 +383,7 @@ module Email
|
|||
@mail[:subject].to_s[
|
||||
/\A\s*(Auto:|Automatic reply|Autosvar|Automatisk svar|Automatisch antwoord|Abwesenheitsnotiz|Risposta Non al computer|Automatisch antwoord|Auto Response|Respuesta automática|Fuori sede|Out of Office|Frånvaro|Réponse automatique)/i
|
||||
] ||
|
||||
@mail.header.to_s[
|
||||
@mail.header.reject { |h| h.name.downcase == "x-auto-response-suppress" }.to_s[
|
||||
/auto[\-_]?(response|submitted|replied|reply|generated|respond)|holidayreply|machinegenerated/i
|
||||
]
|
||||
end
|
||||
|
|
10
spec/fixtures/emails/quirks_exchange_xars.eml
vendored
Normal file
10
spec/fixtures/emails/quirks_exchange_xars.eml
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
Return-Path: <discourse@bar.com>
|
||||
From: Foo Bar <discourse@bar.com>
|
||||
To: reply+4f97315cc828096c9cb34c6f1a0d6fe8@bar.com
|
||||
Date: Fri, 15 Jan 2016 00:12:43 +0100
|
||||
Message-ID: <21@foo.bar.mail>
|
||||
Mime-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
|
||||
|
||||
Some thing.
|
|
@ -521,6 +521,10 @@ RSpec.describe Email::Receiver do
|
|||
expect { process(:invalid_from_2) }.to raise_error(Email::Receiver::NoSenderDetectedError)
|
||||
end
|
||||
|
||||
it "doesn't raise an AutoGeneratedEmailError due to an X-Auto-Response-Suppress header" do
|
||||
expect { process(:quirks_exchange_xars) }.to change { topic.posts.count }
|
||||
end
|
||||
|
||||
it "doesn't raise an AutoGeneratedEmailError when the mail is auto generated but is allowlisted" do
|
||||
SiteSetting.auto_generated_allowlist = "foo@bar.com|discourse@bar.com"
|
||||
expect { process(:auto_generated_allowlisted) }.to change { topic.posts.count }
|
||||
|
|
Loading…
Reference in New Issue
Block a user