UX: display text & html parts alongside raw email in incoming email modal

This commit is contained in:
Régis Hanol
2017-03-08 23:15:42 +01:00
parent dfd5b06c82
commit 00380d84c5
7 changed files with 144 additions and 19 deletions

View File

@ -29,4 +29,21 @@ module Email
name ? name.gsub(/[:<>,"]/, '') : name
end
def self.extract_parts(raw)
mail = Mail.new(raw)
text = nil
html = nil
if mail.multipart?
text = mail.text_part
html = mail.html_part
elsif mail.content_type.to_s["text/html"]
html = mail
else
text = mail
end
[text&.decoded, html&.decoded]
end
end