diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index a0056d82c..bf42176a4 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -2235,9 +2235,6 @@ en: %{message} - --- - %{respond_instructions} - digest: why: "A brief summary of %{site_link} since your last visit on %{last_seen_at}" subject_template: "[%{site_name}] Digest" diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index f742733c6..40e21e9b4 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -375,7 +375,8 @@ module Email options[:raw] << "" << "\n" end - manager = NewPostManager.new(options[:user], options) + user = options.delete(:user) + manager = NewPostManager.new(user, options) result = manager.perform raise InvalidPost, result.errors.full_messages.join("\n") if result.errors.any? @@ -383,7 +384,7 @@ module Email if result.post @incoming_email.update_columns(topic_id: result.post.topic_id, post_id: result.post.id) if result.post.topic && result.post.topic.private_message? - add_other_addresses(result.post.topic, options[:user]) + add_other_addresses(result.post.topic, user) end end end diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb index 01afbb6f8..1003bcb2e 100644 --- a/spec/components/email/receiver_spec.rb +++ b/spec/components/email/receiver_spec.rb @@ -327,6 +327,21 @@ describe Email::Receiver do expect { process(:new_user) }.to change(Topic, :count) end + it "works when approving is enabled" do + SiteSetting.approve_unless_trust_level = 4 + + Fabricate(:user, email: "tl3@bar.com", trust_level: TrustLevel[3]) + Fabricate(:user, email: "tl4@bar.com", trust_level: TrustLevel[4]) + + category.set_permissions(Group[:trust_level_4] => :full) + category.save + + Group.refresh_automatic_group!(:trust_level_4) + + expect { process(:tl3_user) }.to_not change(Topic, :count) + expect { process(:tl4_user) }.to change(Topic, :count) + end + end end diff --git a/spec/fixtures/emails/tl3_user.eml b/spec/fixtures/emails/tl3_user.eml new file mode 100644 index 000000000..307915b42 --- /dev/null +++ b/spec/fixtures/emails/tl3_user.eml @@ -0,0 +1,11 @@ +Return-Path: +From: Foo Bar +To: category@foo.com +Subject: This is a topic from a TL3 user +Date: Fri, 15 Jan 2016 00:12:43 +0100 +Message-ID: <43@foo.bar.mail> +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +Hey, this is a topic from a TL3 user :) diff --git a/spec/fixtures/emails/tl4_user.eml b/spec/fixtures/emails/tl4_user.eml new file mode 100644 index 000000000..3a942c81f --- /dev/null +++ b/spec/fixtures/emails/tl4_user.eml @@ -0,0 +1,11 @@ +Return-Path: +From: Foo Bar +To: category@foo.com +Subject: This is a topic from a TL4 user +Date: Fri, 15 Jan 2016 00:12:43 +0100 +Message-ID: <44@foo.bar.mail> +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +Hey, this is a topic from a TL4 user :)