Commit 9d9df4fe authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

fixup! mixin/mail_message: more robust algorythm to choose the first preferred text format part.

parent 0b16a659
Pipeline #14937 failed with stage
in 0 seconds
......@@ -1018,8 +1018,7 @@ class TestCRMMailIngestion(BaseTestCRM):
part.set_payload(html_message)
encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment',
filename=html_filename)
part.add_header('Content-Disposition', 'attachment')
part.add_header('Content-ID', '<%s>' % \
''.join(['%s' % ord(i) for i in html_filename]))
message.attach(part)
......@@ -1030,6 +1029,15 @@ class TestCRMMailIngestion(BaseTestCRM):
self.assertTrue(bool(event.getAttachmentData(1)))
self.assertTrue(bool(event.getAttachmentData(2)))
def test_getMessageTextPart(self):
portal_type = 'Mail Message'
event = self.portal.getDefaultModule(portal_type).newContent(portal_type=portal_type)
for filename in ('gmail.eml', 'outlook.eml', 'roundcube.eml'):
file_path = '%s/test_data/%s' % (
os.path.dirname(Products.ERP5.tests.__file__),
filename)
event.setData(open(file_path).read())
self.assertTrue(event.getTextContent().startswith('<'))
......
MIME-Version: 1.0
From: Test <test@gmail.com>
Date: Thu, 15 Apr 2021 10:32:20 +0200
Message-ID: <CALqEfxfJAfJd5qHTKo0=bAp75PBPBuDLzqtLNvTVhvOYhRt_DA@mail.gmail.com>
Subject: test gmail
To: Test <test@nexedi.com>
Content-Type: multipart/mixed; boundary="0000000000005ee8f605bffeb4d1"
--0000000000005ee8f605bffeb4d1
Content-Type: multipart/alternative; boundary="0000000000005ee8f305bffeb4cf"
--0000000000005ee8f305bffeb4cf
Content-Type: text/plain; charset="UTF-8"
test gmail
--0000000000005ee8f305bffeb4cf
Content-Type: text/html; charset="UTF-8"
<div dir="ltr">test gmail</div>
--0000000000005ee8f305bffeb4cf--
--0000000000005ee8f605bffeb4d1
Content-Type: image/png; name="white.png"
Content-Disposition: attachment; filename="white.png"
Content-Transfer-Encoding: base64
Content-ID: <f_knimjntc1>
X-Attachment-Id: f_knimjntc1
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQAAAAA3iMLMAAAABGdBTUEAALGPC/xhBQAAACBjSFJN
AAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAd2KE6QAAAAHdElN
RQflBA8MHjIyMgE8AAAADklEQVQI12P4/5+BFAQA/U4f4XOLpqwAAAAldEVYdGRhdGU6Y3JlYXRl
ADIwMjEtMDQtMTVUMTA6MzA6NTArMDI6MDDpJ1gdAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTA0
LTE1VDEwOjMwOjUwKzAyOjAwmHrgoQAAAABJRU5ErkJggg==
--0000000000005ee8f605bffeb4d1--
From: Test <test@outlook.com>
To: Test <test@nexedi.com>
Subject: test outlook
Date: Thu, 15 Apr 2021 08:33:31 +0000
Message-ID:
<PA4PR06MB7264A7A59948017041BDACC6EB4D9@PA4PR06MB7264.eurprd06.prod.outlook.com>
Content-Type: multipart/mixed;
boundary="_004_PA4PR06MB7264A7A59948017041BDACC6EB4D9PA4PR06MB7264eurp_"
MIME-Version: 1.0
--_004_PA4PR06MB7264A7A59948017041BDACC6EB4D9PA4PR06MB7264eurp_
Content-Type: multipart/alternative;
boundary="_000_PA4PR06MB7264A7A59948017041BDACC6EB4D9PA4PR06MB7264eurp_"
--_000_PA4PR06MB7264A7A59948017041BDACC6EB4D9PA4PR06MB7264eurp_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
test outlook
--_000_PA4PR06MB7264A7A59948017041BDACC6EB4D9PA4PR06MB7264eurp_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none;"> P {margin-top:0;margin-bo=
ttom:0;} </style>
</head>
<body dir=3D"ltr">
<div style=3D"font-family: Calibri, Arial, Helvetica, sans-serif; font-size=
: 12pt; color: rgb(0, 0, 0);">
test outlook</div>
</body>
</html>
--_000_PA4PR06MB7264A7A59948017041BDACC6EB4D9PA4PR06MB7264eurp_--
--_004_PA4PR06MB7264A7A59948017041BDACC6EB4D9PA4PR06MB7264eurp_
Content-Type: image/png; name="white.png"
Content-Description: white.png
Content-Disposition: attachment; filename="white.png"; size=262;
creation-date="Thu, 15 Apr 2021 08:33:28 GMT";
modification-date="Thu, 15 Apr 2021 08:33:31 GMT"
Content-Transfer-Encoding: base64
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQAAAAA3iMLMAAAABGdBTUEAALGPC/xhBQAAACBjSFJN
AAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAd2KE6QAAAAHdElN
RQflBA8MHjIyMgE8AAAADklEQVQI12P4/5+BFAQA/U4f4XOLpqwAAAAldEVYdGRhdGU6Y3JlYXRl
ADIwMjEtMDQtMTVUMTA6MzA6NTArMDI6MDDpJ1gdAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTA0
LTE1VDEwOjMwOjUwKzAyOjAwmHrgoQAAAABJRU5ErkJggg==
--_004_PA4PR06MB7264A7A59948017041BDACC6EB4D9PA4PR06MB7264eurp_--
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="=_862f70c5d3ae68efda7d386a6a83a8a5"
Date: Thu, 15 Apr 2021 10:49:41 +0200
From: test@nexedi.com
To: test@nexedi.com
Subject: test roundcube
Message-ID: <c4c34fcc792479e9bdeea46560650b93@nexedi.com>
--=_862f70c5d3ae68efda7d386a6a83a8a5
Content-Type: multipart/alternative;
boundary="=_06ce16e9fb6dfa7ad799171afb2d6cda"
--=_06ce16e9fb6dfa7ad799171afb2d6cda
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
test roundcube
--=_06ce16e9fb6dfa7ad799171afb2d6cda
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
=3DUTF-8" /></head><body style=3D'font-size: 10pt; font-family: Verdana,Gen=
eva,sans-serif'>
<p>test roundcube</p>
</body></html>
--=_06ce16e9fb6dfa7ad799171afb2d6cda--
--=_862f70c5d3ae68efda7d386a6a83a8a5
Content-Transfer-Encoding: base64
Content-Type: image/png;
name=white.png
Content-Disposition: attachment;
filename=white.png;
size=262
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQAAAAA3iMLMAAAABGdBTUEAALGPC/xhBQAAACBjSFJN
AAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAd2KE6QAAAAHdElN
RQflBA8MHjIyMgE8AAAADklEQVQI12P4/5+BFAQA/U4f4XOLpqwAAAAldEVYdGRhdGU6Y3JlYXRl
ADIwMjEtMDQtMTVUMTA6MzA6NTArMDI6MDDpJ1gdAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTA0
LTE1VDEwOjMwOjUwKzAyOjAwmHrgoQAAAABJRU5ErkJggg==
--=_862f70c5d3ae68efda7d386a6a83a8a5--
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment