From eb453d0f820060d79fb1fdac34f39cf28c2a1bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Thu, 1 Dec 2016 18:43:56 +0100 Subject: [PATCH] the note in a FWed email should be a whisper only in PM and when the author is member of the group --- lib/email/receiver.rb | 5 ++++- spec/components/email/receiver_spec.rb | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index 45a722d6c29..b64c250957f 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -420,11 +420,14 @@ module Email end if post && post.topic && @before_embedded.present? + post_type = Post.types[:regular] + post_type = Post.types[:whisper] if post.topic.private_message? && group.usernames[user.username] + create_reply(user: user, raw: @before_embedded, post: post, topic: post.topic, - post_type: Post.types[:whisper]) + post_type: post_type) end true diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb index 935fe3be060..0a7b0a1bed0 100644 --- a/spec/components/email/receiver_spec.rb +++ b/spec/components/email/receiver_spec.rb @@ -394,9 +394,14 @@ describe Email::Receiver do expect(forwarded_post.raw).to match(/XoXo/) expect(last_post.raw).to match(/can you have a look at this email below/) + + expect(last_post.post_type).to eq(Post.types[:regular]) end it "handles weirdly forwarded emails" do + group.add(Fabricate(:user, email: "ba@bar.com")) + group.save + SiteSetting.enable_forwarded_emails = true expect { process(:forwarded_email_2) }.to change(Topic, :count) @@ -407,6 +412,8 @@ describe Email::Receiver do expect(forwarded_post.raw).to match(/XoXo/) expect(last_post.raw).to match(/can you have a look at this email below/) + + expect(last_post.post_type).to eq(Post.types[:whisper]) end end