Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Add small action post to indicate forwarded email

Gerhard Schlager453bec9394d2
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index f8bb80d9779..8c36aa47dda 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -184,6 +184,7 @@ en:
banner:
enabled: "made this a banner %{when}. It will appear at the top of every page until it is dismissed by the user."
disabled: "removed this banner %{when}. It will no longer appear at the top of every page."
+ forwarded: "forwarded the above email"
topic_admin_menu: "topic actions"
diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb
index a66c8cf0302..69f7ccf2704 100644
--- a/lib/email/receiver.rb
+++ b/lib/email/receiver.rb
@@ -844,7 +844,7 @@ module Email
embedded_user: lambda { find_or_create_user(email, display_name) })
return false unless post
- if post&.topic
+ if post.topic
# mark post as seen for the forwarder
PostTiming.record_timing(user_id: user.id, topic_id: post.topic_id, post_number: post.post_number, msecs: 5000)
@@ -859,6 +859,8 @@ module Email
topic: post.topic,
post_type: post_type,
skip_validations: user.staged?)
+ else
+ post.topic.add_small_action(user, "forwarded")
end
end
diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb
index ca7b9257a6e..a7dd5e6b71c 100644
--- a/spec/components/email/receiver_spec.rb
+++ b/spec/components/email/receiver_spec.rb
@@ -888,6 +888,18 @@ describe Email::Receiver do
expect { process(:forwarded_email_3) }.to change(Topic, :count)
end
+ it "adds a small action post to explain who forwarded the email when the sender didn't write anything" do
+ expect { process(:forwarded_email_4) }.to change(Topic, :count)
+
+ forwarded_post, last_post = *Post.last(2)
+
+ expect(forwarded_post.user.email).to eq("[email protected]")
+ expect(forwarded_post.raw).to match(/XoXo/)
+
+ expect(last_post.user.email).to eq("[email protected]")
+ expect(last_post.post_type).to eq(Post.types[:small_action])
+ expect(last_post.action_code).to eq("forwarded")
+ end
end
context "with forwarded emails behaviour set to quote" do
diff --git a/spec/fixtures/emails/forwarded_email_4.eml b/spec/fixtures/emails/forwarded_email_4.eml
new file mode 100644
index 00000000000..c50c1d129a1
--- /dev/null
+++ b/spec/fixtures/emails/forwarded_email_4.eml
@@ -0,0 +1,17 @@
+Message-ID: <[email protected]>
+From: Ba Bar <[email protected]>
+To: Team <[email protected]>
+Date: Mon, 1 Dec 2016 13:37:42 +0100
+Subject: Fwd: Discoursing much?
+
+---------- Forwarded message ---------
+From: Some One <[email protected]>
+To: Ba Bar <[email protected]>
+Date: Mon, 1 Dec 2016 00:13:37 +0100
+Subject: Discoursing much?
+
+Hello Ba Bar,
+
+Discoursing much today?
+
+XoXo