mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
UX: display text & html parts alongside raw email in incoming email modal
This commit is contained in:
17
lib/email.rb
17
lib/email.rb
@ -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
|
||||
|
Reference in New Issue
Block a user