mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 05:40:43 +08:00
FIX: don't send out elided message in email notifications
UX: improved details tag for elided messages
This commit is contained in:
parent
bf209d8344
commit
6d84a8a1b3
|
@ -50,6 +50,7 @@ en:
|
||||||
emails:
|
emails:
|
||||||
incoming:
|
incoming:
|
||||||
default_subject: "Incoming email from %{email}"
|
default_subject: "Incoming email from %{email}"
|
||||||
|
show_trimmed_content: "Show trimmed content"
|
||||||
errors:
|
errors:
|
||||||
empty_email_error: "Happens when the raw mail we received was blank."
|
empty_email_error: "Happens when the raw mail we received was blank."
|
||||||
no_message_id_error: "Happens when the mail has no 'Message-Id' header."
|
no_message_id_error: "Happens when the mail has no 'Message-Id' header."
|
||||||
|
|
|
@ -56,9 +56,14 @@ module Email
|
||||||
@incoming_email.update_columns(user_id: user.id)
|
@incoming_email.update_columns(user_id: user.id)
|
||||||
|
|
||||||
body, elided = select_body
|
body, elided = select_body
|
||||||
|
|
||||||
body ||= ""
|
body ||= ""
|
||||||
body << "\n\n[details=...]\n#{elided}\n[/details]" if elided.present?
|
|
||||||
|
if elided.present?
|
||||||
|
body << "\n\n" << "<details class='elided'>" << "\n"
|
||||||
|
body << "<summary title='#{I18n.t('emails.incoming.show_trimmed_content')}'>···</summary>" << "\n"
|
||||||
|
body << elided << "\n"
|
||||||
|
body << "</details>" << "\n"
|
||||||
|
end
|
||||||
|
|
||||||
raise AutoGeneratedEmailError if is_auto_generated?
|
raise AutoGeneratedEmailError if is_auto_generated?
|
||||||
raise NoBodyDetectedError if body.blank? && !@mail.has_attachments?
|
raise NoBodyDetectedError if body.blank? && !@mail.has_attachments?
|
||||||
|
|
|
@ -23,4 +23,6 @@
|
||||||
return text;
|
return text;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Discourse.Markdown.whiteListTag("details", "class", "elided");
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -7,6 +7,11 @@ details .lightbox-wrapper {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
details,
|
||||||
|
summary {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
summary:first-of-type {
|
summary:first-of-type {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: block;
|
display: block;
|
||||||
|
@ -36,3 +41,33 @@ summary::-webkit-details-marker {
|
||||||
details .lazyYT-container {
|
details .lazyYT-container {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.elided {
|
||||||
|
color: dark-light-choose(scale-color($primary, $lightness: 65%), scale-color($secondary, $lightness: 35%));
|
||||||
|
|
||||||
|
summary:before {
|
||||||
|
content: '' !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
summary {
|
||||||
|
@include unselectable;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
color: #aaa;
|
||||||
|
background: #f1f1f1;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
width: 20px;
|
||||||
|
display: flex;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
line-height: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
summary:hover {
|
||||||
|
color: #222;
|
||||||
|
background: #d8d8d8;
|
||||||
|
border-color: #cdcdcd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# name: discourse-details
|
# name: discourse-details
|
||||||
# about: HTML5.1 Details polyfill for Discourse
|
# about: HTML5.1 Details polyfill for Discourse
|
||||||
# version: 0.3
|
# version: 0.4
|
||||||
# authors: Régis Hanol
|
# authors: Régis Hanol
|
||||||
# url: https://github.com/discourse/discourse/tree/master/plugins/discourse-details
|
# url: https://github.com/discourse/discourse/tree/master/plugins/discourse-details
|
||||||
|
|
||||||
|
@ -13,14 +13,15 @@ register_asset "stylesheets/details.scss"
|
||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
|
|
||||||
# replace all details with their summary in emails
|
|
||||||
Email::Styles.register_plugin_style do |fragment|
|
Email::Styles.register_plugin_style do |fragment|
|
||||||
if SiteSetting.details_enabled
|
# remove all elided content
|
||||||
fragment.css("details").each do |details|
|
fragment.css("details.elided").each { |d| d.remove }
|
||||||
summary = details.css("summary")[0]
|
|
||||||
summary.name = "p"
|
# replace all details with their summary in emails
|
||||||
details.replace(summary)
|
fragment.css("details").each do |details|
|
||||||
end
|
summary = details.css("summary")[0]
|
||||||
|
summary.name = "p"
|
||||||
|
details.replace(summary)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ describe Email::Receiver do
|
||||||
|
|
||||||
it "removes the 'on <date>, <contact> wrote' quoting line" do
|
it "removes the 'on <date>, <contact> wrote' quoting line" do
|
||||||
expect { process(:on_date_contact_wrote) }.to change { topic.posts.count }
|
expect { process(:on_date_contact_wrote) }.to change { topic.posts.count }
|
||||||
expect(topic.posts.last.raw).to eq("This is the actual reply.\n\n[details=...]\nOn Tue, Jan 14, 2016 at 0:42 AM, Bar Foo <wat@discourse.org> wrote:\n\n> This is the previous email.\n> And it had\n>\n> a lot\n>\n>\n> of lines ;)\n[/details]")
|
expect(topic.posts.last.raw).to eq("This is the actual reply.\n\n<details class='elided'>\n<summary title='Show trimmed content'>···</summary>\nOn Tue, Jan 14, 2016 at 0:42 AM, Bar Foo <wat@discourse.org> wrote:\n\n> This is the previous email.\n> And it had\n>\n> a lot\n>\n>\n> of lines ;)\n</details>")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "removes the 'Previous Replies' marker" do
|
it "removes the 'Previous Replies' marker" do
|
||||||
|
@ -193,7 +193,7 @@ describe Email::Receiver do
|
||||||
|
|
||||||
it "strips 'original message' context" do
|
it "strips 'original message' context" do
|
||||||
expect { process(:original_message) }.to change { topic.posts.count }
|
expect { process(:original_message) }.to change { topic.posts.count }
|
||||||
expect(topic.posts.last.raw).to eq("This is a reply :)\n\n[details=...]\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 "supports attached images" do
|
it "supports attached images" do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user