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
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
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:
...
@@ -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_maintype
()
==
'text'
and
not
subpart
.
get_filename
():
if
subpart
.
get_content_type
()
==
preferred_content_type
:
if
subpart
.
get_content_type
()
==
preferred_content_type
:
part_list
.
insert
(
0
,
subpart
)
found_part_list
.
insert
(
0
,
subpart
)
else
:
break
part_list
.
append
(
subpart
)
elif
not
found_part_list
:
found_part_list
.
append
(
subpart
)
else
:
else
:
part_list
.
extend
(
part
.
get_payload
())
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