mirror of
https://github.com/discourse/discourse.git
synced 2025-09-10 17:26:30 +08:00
FEATURE: convert incoming emails in HTML to markdown
- remove incoming_email_prefer_html site setting - remove HtmlCleaner class
This commit is contained in:
parent
e155cb6db1
commit
b76674f640
6 changed files with 10 additions and 157 deletions
|
@ -1,7 +1,7 @@
|
|||
require "digest"
|
||||
require_dependency "new_post_manager"
|
||||
require_dependency "post_action_creator"
|
||||
require_dependency "email/html_cleaner"
|
||||
require_dependency "html_to_markdown"
|
||||
|
||||
module Email
|
||||
|
||||
|
@ -188,18 +188,18 @@ module Email
|
|||
text = fix_charset(@mail)
|
||||
end
|
||||
|
||||
if html.present? && (SiteSetting.incoming_email_prefer_html || text.blank?)
|
||||
html = Email::HtmlCleaner.new(html).output_html
|
||||
html = trim_discourse_markers(html)
|
||||
html, elided = EmailReplyTrimmer.trim(html, true)
|
||||
return [html, elided]
|
||||
end
|
||||
|
||||
if text.present?
|
||||
text = trim_discourse_markers(text)
|
||||
text, elided = EmailReplyTrimmer.trim(text, true)
|
||||
return [text, elided]
|
||||
end
|
||||
|
||||
if html.present?
|
||||
markdown = HtmlToMarkdown.new(html).to_markdown
|
||||
markdown = trim_discourse_markers(markdown)
|
||||
markdown, elided = EmailReplyTrimmer.trim(markdown, true)
|
||||
return [markdown, elided]
|
||||
end
|
||||
end
|
||||
|
||||
def fix_charset(mail_part)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue