ignore some site settings for emails sent to mailinglist mirror category
This commit is contained in:
parent
aea161fabd
commit
1a3ab7c02e
|
@ -105,7 +105,10 @@ module Email
|
||||||
|
|
||||||
if is_auto_generated?
|
if is_auto_generated?
|
||||||
@incoming_email.update_columns(is_auto_generated: true)
|
@incoming_email.update_columns(is_auto_generated: true)
|
||||||
raise AutoGeneratedEmailError if SiteSetting.block_auto_generated_emails?
|
|
||||||
|
if SiteSetting.block_auto_generated_emails? && !sent_to_mailinglist_mirror?
|
||||||
|
raise AutoGeneratedEmailError
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if action = subscription_action_for(body, subject)
|
if action = subscription_action_for(body, subject)
|
||||||
|
@ -374,9 +377,20 @@ module Email
|
||||||
end
|
end
|
||||||
|
|
||||||
def destinations
|
def destinations
|
||||||
all_destinations
|
@destinations ||= all_destinations
|
||||||
.map { |d| Email::Receiver.check_address(d) }
|
.map { |d| Email::Receiver.check_address(d) }
|
||||||
.drop_while(&:blank?)
|
.reject(&:blank?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def sent_to_mailinglist_mirror?
|
||||||
|
destinations.each do |destination|
|
||||||
|
next unless destination[:type] == :category
|
||||||
|
|
||||||
|
category = destination[:obj]
|
||||||
|
return true if category.mailinglist_mirror?
|
||||||
|
end
|
||||||
|
|
||||||
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.check_address(address)
|
def self.check_address(address)
|
||||||
|
@ -573,7 +587,7 @@ module Email
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_related_post
|
def find_related_post
|
||||||
return if SiteSetting.find_related_post_with_key
|
return if SiteSetting.find_related_post_with_key && !sent_to_mailinglist_mirror?
|
||||||
|
|
||||||
message_ids = [@mail.in_reply_to, Email::Receiver.extract_references(@mail.references)]
|
message_ids = [@mail.in_reply_to, Email::Receiver.extract_references(@mail.references)]
|
||||||
message_ids.flatten!
|
message_ids.flatten!
|
||||||
|
|
|
@ -795,4 +795,23 @@ describe Email::Receiver do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "mailinglist mirror" do
|
||||||
|
before do
|
||||||
|
SiteSetting.block_auto_generated_emails = true
|
||||||
|
SiteSetting.find_related_post_with_key = true
|
||||||
|
|
||||||
|
Fabricate(:mailinglist_mirror_category)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should allow creating topic even when email is autogenerated" do
|
||||||
|
expect { process(:mailinglist) }.to change { Topic.count }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should allow replying without reply key" do
|
||||||
|
process(:mailinglist)
|
||||||
|
topic = Topic.last
|
||||||
|
|
||||||
|
expect { process(:mailinglist_reply) }.to change { topic.posts.count }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
From: alice@foo.com
|
||||||
|
To: list@example.com
|
||||||
|
Subject: mailinglist mirror
|
||||||
|
Date: Mon, 16 Oct 2017 09:18:32 +0100
|
||||||
|
Message-ID: <bddaa334ef93b5f3c7c3a42599330844@foo.com>
|
||||||
|
Precedence: list
|
||||||
|
List-Id: Example List <list@example.com>
|
||||||
|
Content-Transfer-Encoding: 7bit
|
||||||
|
Content-Type: text/plain; charset="us-ascii"
|
||||||
|
Sender: list-bounces@example.com
|
||||||
|
|
||||||
|
I love Discourse's mailinglist mirror feature.
|
|
@ -0,0 +1,16 @@
|
||||||
|
In-Reply-To: <bddaa334ef93b5f3c7c3a42599330844@foo.com>
|
||||||
|
References: <bddaa334ef93b5f3c7c3a42599330844@foo.com>
|
||||||
|
From: bob@bar.com
|
||||||
|
To: list@example.com
|
||||||
|
Subject: Re: mailinglist mirror
|
||||||
|
Date: Mon, 16 Oct 2017 09:41:26 +0100
|
||||||
|
Message-ID: <CACJSOXnUonfJqMggzKYsZX@bar.com>
|
||||||
|
Precedence: list
|
||||||
|
List-Id: Example List <list@example.com>
|
||||||
|
Content-Transfer-Encoding: 7bit
|
||||||
|
Content-Type: text/plain; charset="us-ascii"
|
||||||
|
Sender: list-bounces@example.com
|
||||||
|
|
||||||
|
> I love Discourse's mailinglist mirror feature.
|
||||||
|
|
||||||
|
Me too!
|
Loading…
Reference in New Issue