mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Allow inclusion of elided text from emails when sending to a category… (#4844)
* Allow inclusion of elided text from emails when sending to a category address
This commit is contained in:
parent
e12601b850
commit
9294826f31
3 changed files with 41 additions and 0 deletions
|
@ -374,6 +374,7 @@ module Email
|
||||||
|
|
||||||
create_topic(user: user,
|
create_topic(user: user,
|
||||||
raw: body,
|
raw: body,
|
||||||
|
elided: elided,
|
||||||
title: subject,
|
title: subject,
|
||||||
category: category.id,
|
category: category.id,
|
||||||
skip_validations: user.staged?)
|
skip_validations: user.staged?)
|
||||||
|
|
|
@ -309,6 +309,18 @@ describe Email::Receiver do
|
||||||
expect(topic.posts.last.raw).to eq("This is a reply :)\n\n<details class='elided'>\n<summary title='Show trimmed content'>···</summary>\n---Original Message---\nThis part should not be included\n</details>")
|
expect(topic.posts.last.raw).to eq("This is a reply :)\n\n<details class='elided'>\n<summary title='Show trimmed content'>···</summary>\n---Original Message---\nThis part should not be included\n</details>")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't include the 'elided' part of the original message when always_show_trimmed_content is disabled" do
|
||||||
|
SiteSetting.always_show_trimmed_content = false
|
||||||
|
expect { process(:original_message) }.to change { topic.posts.count }.from(1).to(2)
|
||||||
|
expect(topic.posts.last.raw).to eq("This is a reply :)")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "adds the 'elided' part of the original message for public replies when always_show_trimmed_content is enabled" do
|
||||||
|
SiteSetting.always_show_trimmed_content = true
|
||||||
|
expect { process(:original_message) }.to change { topic.posts.count }.from(1).to(2)
|
||||||
|
expect(topic.posts.last.raw).to eq("This is a reply :)\n\n<details class='elided'>\n<summary title='Show trimmed content'>···</summary>\n---Original Message---\nThis part should not be included\n</details>")
|
||||||
|
end
|
||||||
|
|
||||||
it "supports attached images in TEXT part" do
|
it "supports attached images in TEXT part" do
|
||||||
SiteSetting.queue_jobs = true
|
SiteSetting.queue_jobs = true
|
||||||
|
|
||||||
|
@ -483,6 +495,16 @@ describe Email::Receiver do
|
||||||
expect { process(:new_user) }.to change(Topic, :count)
|
expect { process(:new_user) }.to change(Topic, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "adds the 'elided' part of the original message when always_show_trimmed_content is enabled" do
|
||||||
|
SiteSetting.always_show_trimmed_content = true
|
||||||
|
|
||||||
|
user = Fabricate(:user, email: "existing@bar.com", trust_level: SiteSetting.email_in_min_trust)
|
||||||
|
expect { process(:forwarded_email_to_category) }.to change{Topic.count}.by(1) # Topic created
|
||||||
|
|
||||||
|
new_post, = Post.last
|
||||||
|
expect(new_post.raw).to include("Hi everyone, can you have a look at the email below?","<summary title='Show trimmed content'>···</summary>","Discoursing much today?")
|
||||||
|
end
|
||||||
|
|
||||||
it "works when approving is enabled" do
|
it "works when approving is enabled" do
|
||||||
SiteSetting.approve_unless_trust_level = 4
|
SiteSetting.approve_unless_trust_level = 4
|
||||||
|
|
||||||
|
|
18
spec/fixtures/emails/forwarded_email_to_category.eml
vendored
Normal file
18
spec/fixtures/emails/forwarded_email_to_category.eml
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
Message-ID: <61@foo.bar.mail>
|
||||||
|
From: Foo Bar <existing@bar.com>
|
||||||
|
To: Category <category@bar.com>
|
||||||
|
Date: Mon, 1 Dec 2016 13:37:42 +0100
|
||||||
|
Subject: FW: Discoursing much?
|
||||||
|
|
||||||
|
Hi everyone, can you have a look at the email below?
|
||||||
|
|
||||||
|
From: Some One <some@one.com>
|
||||||
|
To: Ba Bar <ba@bar.com>
|
||||||
|
Date: Mon, 1 Dec 2016 00:13:37 +0100
|
||||||
|
Subject: Discoursing much?
|
||||||
|
|
||||||
|
Hello Ba Bar,
|
||||||
|
|
||||||
|
Discoursing much today?
|
||||||
|
|
||||||
|
XoXo
|
Loading…
Add table
Add a link
Reference in a new issue