mirror of
https://github.com/discourse/discourse.git
synced 2025-06-17 16:32:43 +08:00
FIX: elided part of incoming email was dismissed when creating a new topic
This commit is contained in:
@ -201,7 +201,6 @@ module Email
|
|||||||
def select_body
|
def select_body
|
||||||
text = nil
|
text = nil
|
||||||
html = nil
|
html = nil
|
||||||
elided = nil
|
|
||||||
|
|
||||||
if @mail.multipart?
|
if @mail.multipart?
|
||||||
text = fix_charset(@mail.text_part)
|
text = fix_charset(@mail.text_part)
|
||||||
@ -212,21 +211,18 @@ module Email
|
|||||||
text = fix_charset(@mail)
|
text = fix_charset(@mail)
|
||||||
end
|
end
|
||||||
|
|
||||||
use_html = html.present? && (!text.present? || SiteSetting.incoming_email_prefer_html)
|
if html.present? && (SiteSetting.incoming_email_prefer_html || text.blank?)
|
||||||
use_text = text.present? unless use_html
|
|
||||||
|
|
||||||
if use_text
|
|
||||||
text = trim_discourse_markers(text)
|
|
||||||
text, elided = EmailReplyTrimmer.trim(text, true)
|
|
||||||
return [text, elided]
|
|
||||||
end
|
|
||||||
|
|
||||||
if use_html
|
|
||||||
html = Email::HtmlCleaner.new(html).output_html
|
html = Email::HtmlCleaner.new(html).output_html
|
||||||
html = trim_discourse_markers(html)
|
html = trim_discourse_markers(html)
|
||||||
html, elided = EmailReplyTrimmer.trim(html, true)
|
html, elided = EmailReplyTrimmer.trim(html, true)
|
||||||
return [html, elided]
|
return [html, elided]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if text.present?
|
||||||
|
text = trim_discourse_markers(text)
|
||||||
|
text, elided = EmailReplyTrimmer.trim(text, true)
|
||||||
|
return [text, elided]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_charset(mail_part)
|
def fix_charset(mail_part)
|
||||||
@ -454,8 +450,11 @@ module Email
|
|||||||
# ensure posts aren't created in the future
|
# ensure posts aren't created in the future
|
||||||
options[:created_at] = [@mail.date, DateTime.now].min
|
options[:created_at] = [@mail.date, DateTime.now].min
|
||||||
|
|
||||||
|
is_private_message = options[:archetype] == Archetype.private_message ||
|
||||||
|
options[:topic].try(:private_message?)
|
||||||
|
|
||||||
# only add elided part in messages
|
# only add elided part in messages
|
||||||
if @elided.present? && options[:topic].try(:private_message?)
|
if @elided.present? && is_private_message
|
||||||
options[:raw] << "\n\n" << "<details class='elided'>" << "\n"
|
options[:raw] << "\n\n" << "<details class='elided'>" << "\n"
|
||||||
options[:raw] << "<summary title='#{I18n.t('emails.incoming.show_trimmed_content')}'>···</summary>" << "\n"
|
options[:raw] << "<summary title='#{I18n.t('emails.incoming.show_trimmed_content')}'>···</summary>" << "\n"
|
||||||
options[:raw] << @elided << "\n"
|
options[:raw] << @elided << "\n"
|
||||||
|
Reference in New Issue
Block a user