Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roque
erp5
Commits
6511eab7
Commit
6511eab7
authored
Jun 10, 2020
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mixin/mail_message: more robust algorythm to choose the first preferred text format part.
parent
c916c06f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
product/ERP5/bootstrap/erp5_core/MixinTemplateItem/portal_components/mixin.erp5.MailMessageMixin.py
...lateItem/portal_components/mixin.erp5.MailMessageMixin.py
+14
-15
No files found.
product/ERP5/bootstrap/erp5_core/MixinTemplateItem/portal_components/mixin.erp5.MailMessageMixin.py
View file @
6511eab7
...
...
@@ -84,29 +84,28 @@ class MailMessageMixin:
Based on rfc: http://tools.ietf.org/html/rfc2046#section-5.1.4)
"""
# Default value if no text is found
found_part
=
None
part_list
=
[
self
.
_getMessage
()]
found_part_list
=
[]
preferred_content_type
=
self
.
getPortalObject
().
portal_preferences
.
getPreferredTextFormat
(
'text/html'
)
while
part_list
:
part
=
part_list
.
pop
(
0
)
if
part
.
is_multipart
():
if
part
.
get_content_subtype
()
==
'alternative'
:
if
part
.
get_content_subtype
()
in
(
'alternative'
,
'mixed'
,
'related'
)
:
# Try to get the favourite text format defined on preference
preferred_content_type
=
self
.
getPortalObject
().
portal_preferences
.
\
getPreferredTextFormat
(
'text/html'
)
favourite_part
=
None
for
subpart
in
part
.
get_payload
():
if
subpart
.
get_content_maintype
()
==
'text'
and
not
subpart
.
get_filename
():
if
subpart
.
get_content_type
()
==
preferred_content_type
:
part_list
.
insert
(
0
,
subpart
)
else
:
part_list
.
append
(
subpart
)
found_part_list
.
insert
(
0
,
subpart
)
break
elif
not
found_part_list
:
found_part_list
.
append
(
subpart
)
else
:
part_list
.
extend
(
part
.
get_payload
())
elif
part
.
get_content_maintype
()
==
'text'
:
found_part
=
part
break
return
found_part
found_part_list
.
append
(
part
)
if
found_part_list
:
return
found_part_list
[
0
]
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getContentInformation'
)
def
getContentInformation
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment