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
0
Issues
0
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
Lukas Niegsch
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
Hide 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:
...
@@ -84,29 +84,28 @@ class MailMessageMixin:
Based on rfc: http://tools.ietf.org/html/rfc2046#section-5.1.4)
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
()]
part_list
=
[
self
.
_getMessage
()]
found_part_list
=
[]
preferred_content_type
=
self
.
getPortalObject
().
portal_preferences
.
getPreferredTextFormat
(
'text/html'
)
while
part_list
:
while
part_list
:
part
=
part_list
.
pop
(
0
)
part
=
part_list
.
pop
(
0
)
if
part
.
is_multipart
():
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
# Try to get the favourite text format defined on preference
preferred_content_type
=
self
.
getPortalObject
().
portal_preferences
.
\
favourite_part
=
None
getPreferredTextFormat
(
'text/html'
)
for
subpart
in
part
.
get_payload
():
for
subpart
in
part
.
get_payload
():
if
subpart
.
get_content_type
()
==
preferred_content_type
:
if
subpart
.
get_content_maintype
()
==
'text'
and
not
subpart
.
get_filename
():
part_list
.
insert
(
0
,
subpart
)
if
subpart
.
get_content_type
()
==
preferred_content_type
:
found_part_list
.
insert
(
0
,
subpart
)
break
elif
not
found_part_list
:
found_part_list
.
append
(
subpart
)
else
:
else
:
part_list
.
append
(
subpart
)
part_list
.
extend
(
part
.
get_payload
())
else
:
part_list
.
extend
(
part
.
get_payload
())
elif
part
.
get_content_maintype
()
==
'text'
:
elif
part
.
get_content_maintype
()
==
'text'
:
found_part
=
part
found_part_list
.
append
(
part
)
break
if
found_part_list
:
return
found_part_list
[
0
]
return
found_part
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getContentInformation'
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getContentInformation'
)
def
getContentInformation
(
self
):
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