revert: "fix: html content is available and mail_part empty" (#3986)

Reverts de4e4c6
This commit is contained in:
Pranav Raj S
2022-02-15 17:19:28 +05:30
committed by GitHub
parent 464e12ceb7
commit 505c93c467
3 changed files with 9 additions and 183 deletions

View File

@@ -27,21 +27,17 @@ class MailPresenter < SimpleDelegator
end
# returns encoded mail body text_part if available.
# returns encoded raw mail body as it is if mail_part not available.
# returns encoded mail body as it is if mail_part not available.
# else returns parsed the html body if contains text/html content.
def select_body(mail_part)
decoded = if mail_part
mail_part.decoded
else
raw_mail_body
end
return encoded_mail_body unless mail_part
encoded = encode_to_unicode(decoded)
decoded = encode_to_unicode(mail_part.decoded)
if mail.text_part
encoded
decoded
elsif html_mail_body?
::HtmlParser.parse_reply(encoded)
::HtmlParser.parse_reply(decoded)
end
end
@@ -135,15 +131,12 @@ class MailPresenter < SimpleDelegator
end
def html_mail_body?
((mail.content_type || '').include? 'text/html') || @mail.html_part&.content_type&.include?('text/html')
((mail.content_type || '').include? 'text/html') || @mail.html_part || @mail.html_part.content_type.include?('text/html')
end
def text_mail_body?
((mail.content_type || '').include? 'text') || @mail.text_part&.content_type&.include?('text')
end
def raw_mail_body
return @mail.body.decoded if html_mail_body? || text_mail_body?
# returns mail body if mail content_type is text/plain
def encoded_mail_body
return encode_to_unicode(@mail.body.decoded) if (@mail.content_type || '').include? 'text/plain'
''
end