2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

FEATURE: hide elided part of incoming emails behind a [details] tag

This commit is contained in:
Régis Hanol 2016-03-09 18:51:54 +01:00
parent 1009dc9be1
commit 2747e14b4c
3 changed files with 13 additions and 8 deletions

View file

@ -54,7 +54,11 @@ module Email
def process_internal
user = find_or_create_user(@from_email, @from_display_name)
@incoming_email.update_columns(user_id: user.id)
body = select_body || ""
body, elided = select_body
body ||= ""
body << "\n\n[details=...]\n#{elided}\n[/details]" if elided.present?
raise AutoGeneratedEmailError if is_auto_generated?
raise NoBodyDetectedError if body.blank? && !@mail.has_attachments?
@ -115,6 +119,7 @@ module Email
def select_body
text = nil
html = nil
elided = nil
if @mail.multipart?
text = fix_charset(@mail.text_part)
@ -127,14 +132,14 @@ module Email
# prefer text over html
text = trim_discourse_markers(text) if text.present?
text = EmailReplyTrimmer.trim(text) if text.present?
return text if text.present?
text, elided = EmailReplyTrimmer.trim(text, true) if text.present?
return [text, elided] if text.present?
# clean the html if that's all we've got
html = Email::HtmlCleaner.new(html).output_html if html.present?
html = trim_discourse_markers(html) if html.present?
html = EmailReplyTrimmer.trim(html) if html.present?
return html if html.present?
html, elided = EmailReplyTrimmer.trim(html, true) if html.present?
return [html, elided] if html.present?
end
def fix_charset(mail_part)