revert: "fix: html content is available and mail_part empty" (#3986)
Reverts de4e4c6
This commit is contained in:
@@ -27,21 +27,17 @@ class MailPresenter < SimpleDelegator
|
|||||||
end
|
end
|
||||||
|
|
||||||
# returns encoded mail body text_part if available.
|
# 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.
|
# else returns parsed the html body if contains text/html content.
|
||||||
def select_body(mail_part)
|
def select_body(mail_part)
|
||||||
decoded = if mail_part
|
return encoded_mail_body unless mail_part
|
||||||
mail_part.decoded
|
|
||||||
else
|
|
||||||
raw_mail_body
|
|
||||||
end
|
|
||||||
|
|
||||||
encoded = encode_to_unicode(decoded)
|
decoded = encode_to_unicode(mail_part.decoded)
|
||||||
|
|
||||||
if mail.text_part
|
if mail.text_part
|
||||||
encoded
|
decoded
|
||||||
elsif html_mail_body?
|
elsif html_mail_body?
|
||||||
::HtmlParser.parse_reply(encoded)
|
::HtmlParser.parse_reply(decoded)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -135,15 +131,12 @@ class MailPresenter < SimpleDelegator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def html_mail_body?
|
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
|
end
|
||||||
|
|
||||||
def text_mail_body?
|
# returns mail body if mail content_type is text/plain
|
||||||
((mail.content_type || '').include? 'text') || @mail.text_part&.content_type&.include?('text')
|
def encoded_mail_body
|
||||||
end
|
return encode_to_unicode(@mail.body.decoded) if (@mail.content_type || '').include? 'text/plain'
|
||||||
|
|
||||||
def raw_mail_body
|
|
||||||
return @mail.body.decoded if html_mail_body? || text_mail_body?
|
|
||||||
|
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
|||||||
144
spec/fixtures/files/support_1.eml
vendored
144
spec/fixtures/files/support_1.eml
vendored
@@ -1,144 +0,0 @@
|
|||||||
Date: Fri, 11 Feb 2022 05:15:51 +0000
|
|
||||||
Mime-Version: 1.0
|
|
||||||
Subject: Get Paid to post an article
|
|
||||||
From: sony@chatwoot.com
|
|
||||||
To: care@example.com
|
|
||||||
X-Mailgun-Tag: test1
|
|
||||||
X-Mailgun-Track-Clicks: true
|
|
||||||
X-Mailgun-Track: true
|
|
||||||
X-Mailgun-Track-Opens: true
|
|
||||||
Message-Id: <20220211051551.0ac6490aa10da09b@chatwoot.com>
|
|
||||||
Content-Type: text/html; charset="ascii"
|
|
||||||
Content-Transfer-Encoding: quoted-printable
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title></title>
|
|
||||||
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8=
|
|
||||||
" />
|
|
||||||
<meta name=3D"viewport" content=3D"width=3Ddevice-width, initial-scale=
|
|
||||||
=3D1">
|
|
||||||
<meta http-equiv=3D"X-UA-Compatible" content=3D"IE=3Dedge" />
|
|
||||||
<style type=3D"text/css">
|
|
||||||
@media screen {
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Lato';
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
src: local('Lato Regular'), local('Lato-Regular'), url(http=
|
|
||||||
s://fonts.gstatic.com/s/lato/v11/qIIYRU-oROkIk8vfvxw6QvesZW2xOQ-xsNqO47m55D=
|
|
||||||
A.woff) format('woff');
|
|
||||||
}
|
|
||||||
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Lato';
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 700;
|
|
||||||
src: local('Lato Bold'), local('Lato-Bold'), url(https://fo=
|
|
||||||
nts.gstatic.com/s/lato/v11/qdgUG4U09HnJwhYI-uK18wLUuEpTyoUstqEm5AMlJo4.woff=
|
|
||||||
) format('woff');
|
|
||||||
}
|
|
||||||
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Lato';
|
|
||||||
font-style: italic;
|
|
||||||
font-weight: 400;
|
|
||||||
src: local('Lato Italic'), local('Lato-Italic'), url(https:=
|
|
||||||
//fonts.gstatic.com/s/lato/v11/RYyZNoeFgb0l7W3Vu1aSWOvvDin1pK8aKteLpeZ5c0A.=
|
|
||||||
woff) format('woff');
|
|
||||||
}
|
|
||||||
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Lato';
|
|
||||||
font-style: italic;
|
|
||||||
font-weight: 700;
|
|
||||||
src: local('Lato Bold Italic'), local('Lato-BoldItalic'), u=
|
|
||||||
rl(https://fonts.gstatic.com/s/lato/v11/HkF_qI1x_noxlxhrhMQYELO3LdcAZYWl9Si=
|
|
||||||
6vvxL-qU.woff) format('woff');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* CLIENT-SPECIFIC STYLES */
|
|
||||||
body,
|
|
||||||
table,
|
|
||||||
td,
|
|
||||||
a {
|
|
||||||
-webkit-text-size-adjust: 100%;
|
|
||||||
-ms-text-size-adjust: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
table,
|
|
||||||
td {
|
|
||||||
mso-table-lspace: 0pt;
|
|
||||||
mso-table-rspace: 0pt;
|
|
||||||
}
|
|
||||||
td{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
img {
|
|
||||||
-ms-interpolation-mode: bicubic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* RESET STYLES */
|
|
||||||
img {
|
|
||||||
border: 0;
|
|
||||||
height: auto;
|
|
||||||
line-height: 100%;
|
|
||||||
outline: none;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
border-collapse: collapse !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
height: 100% !important;
|
|
||||||
margin: 0 !important;
|
|
||||||
padding: 0 !important;
|
|
||||||
width: 100% !important;
|
|
||||||
background-color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* iOS BLUE LINKS */
|
|
||||||
a[x-apple-data-detectors] {
|
|
||||||
color: inherit !important;
|
|
||||||
text-decoration: none !important;
|
|
||||||
font-size: inherit !important;
|
|
||||||
font-family: inherit !important;
|
|
||||||
font-weight: inherit !important;
|
|
||||||
line-height: inherit !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* MOBILE STYLES */
|
|
||||||
@media screen and (max-width:600px) {
|
|
||||||
h1 {
|
|
||||||
font-size: 32px !important;
|
|
||||||
line-height: 32px !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ANDROID CENTER FIX */
|
|
||||||
div[style*=3D"margin: 16px 0;"] {
|
|
||||||
margin: 0 !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
Hi,<br /><br />We are providing you platform from here you can sell=
|
|
||||||
paid posts on your website.
|
|
||||||
|
|
||||||
<div style=3D'width:100%'><p>Chatwoot | CS team | <a href=3D"https://d33wubrfki0l68.cloudfront.net/973467c532160fd8b940300a43fa85fa2d060307/dc9a0/static/brand-73f58cdefae282ae74cebfa74c1d7003.svg">C</hatwoota></p>
|
|
||||||
<p>Skype: live:.cid.something</p>
|
|
||||||
</d=
|
|
||||||
iv>
|
|
||||||
</div>
|
|
||||||
<img width=3D"1px" height=3D"1px" alt=3D"" src=3D"https://d33wubrfki0l68.cloudfront.net/973467c532160fd8b940300a43fa85fa2d060307/dc9a0/static/brand-73f58cdefae282ae74cebfa74c1d7003.svg"></=
|
|
||||||
body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -157,29 +157,6 @@ RSpec.describe SupportMailbox, type: :mailbox do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'when mail part is not present' do
|
|
||||||
let(:support_mail) { create_inbound_email_from_fixture('support_1.eml') }
|
|
||||||
let(:described_subject) { described_class.receive support_mail }
|
|
||||||
|
|
||||||
it 'Considers raw html mail body' do
|
|
||||||
described_subject
|
|
||||||
expect(conversation.inbox.id).to eq(channel_email.inbox.id)
|
|
||||||
expect(conversation.messages.last.content).to include(
|
|
||||||
<<-BODY.strip_heredoc.chomp
|
|
||||||
Hi,
|
|
||||||
We are providing you platform from here you can sellpaid posts on your website.
|
|
||||||
|
|
||||||
Chatwoot | CS team | [C](https://d33wubrfki0l68.cloudfront.net/973467c532160fd8b940300a43fa85fa2d060307/dc9a0/static/brand-73f58cdefae282ae74cebfa74c1d7003.svg)
|
|
||||||
|
|
||||||
Skype: live:.cid.something
|
|
||||||
|
|
||||||
[]
|
|
||||||
BODY
|
|
||||||
)
|
|
||||||
expect(conversation.messages.last.content_attributes['email']['subject']).to eq('Get Paid to post an article')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'Sender with reply_to email address' do
|
describe 'Sender with reply_to email address' do
|
||||||
let(:reply_to_mail) { create_inbound_email_from_fixture('reply_to.eml') }
|
let(:reply_to_mail) { create_inbound_email_from_fixture('reply_to.eml') }
|
||||||
let(:email_channel) { create(:channel_email, email: 'test@example.com', account: account) }
|
let(:email_channel) { create(:channel_email, email: 'test@example.com', account: account) }
|
||||||
|
|||||||
Reference in New Issue
Block a user