mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
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
|
||||||
|
BIN
spec/fixtures/emails/mailinglist.eml
vendored
Normal file
BIN
spec/fixtures/emails/mailinglist.eml
vendored
Normal file
Binary file not shown.
BIN
spec/fixtures/emails/mailinglist_reply.eml
vendored
Normal file
BIN
spec/fixtures/emails/mailinglist_reply.eml
vendored
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user