summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alot/commands/thread.py10
-rw-r--r--alot/db/message.py25
-rw-r--r--alot/db/utils.py9
-rw-r--r--alot/widgets/thread.py2
4 files changed, 17 insertions, 29 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 60c46b93..c69aca8b 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -149,10 +149,10 @@ class ReplyCommand(Command):
mailcontent = quotestring
quotehook = settings.get_hook('text_quote')
if quotehook:
- mailcontent += quotehook(self.message.accumulate_body())
+ mailcontent += quotehook(self.message.get_body_text())
else:
quote_prefix = settings.get('quote_prefix')
- for line in self.message.accumulate_body().splitlines():
+ for line in self.message.get_body_text().splitlines():
mailcontent += quote_prefix + line + '\n'
envelope = Envelope(bodytext=mailcontent, replied=self.message)
@@ -327,10 +327,10 @@ class ForwardCommand(Command):
mailcontent = quote
quotehook = settings.get_hook('text_quote')
if quotehook:
- mailcontent += quotehook(self.message.accumulate_body())
+ mailcontent += quotehook(self.message.get_body_text())
else:
quote_prefix = settings.get('quote_prefix')
- for line in self.message.accumulate_body().splitlines():
+ for line in self.message.get_body_text().splitlines():
mailcontent += quote_prefix + line + '\n'
envelope.body = mailcontent
@@ -463,7 +463,7 @@ class EditNewCommand(Command):
'signed', 'encrypted', 'unread', 'attachment'})
tags = list(tags)
# set body text
- mailcontent = self.message.accumulate_body()
+ mailcontent = self.message.get_body_text()
envelope = Envelope(bodytext=mailcontent, tags=tags)
# copy selected headers
diff --git a/alot/db/message.py b/alot/db/message.py
index f756e349..0926e9f4 100644
--- a/alot/db/message.py
+++ b/alot/db/message.py
@@ -18,11 +18,6 @@ from ..settings.const import settings
charset.add_charset('utf-8', charset.QP, charset.QP, 'utf-8')
-MISSING_HTML_MSG = ("This message contains a text/html part that was not "
- "rendered due to a missing mailcap entry. "
- "Please refer to item 5 in our FAQ: "
- "http://alot.rtfd.io/en/latest/faq.html")
-
@functools.total_ordering
class Message:
@@ -265,25 +260,9 @@ class Message:
self._attachments.append(Attachment(part))
return self._attachments
- def accumulate_body(self):
- """
- returns bodystring extracted from this mail
- """
- # TODO: allow toggle commands to decide which part is considered body
- eml = self.get_email()
- bodytext = self.get_body_text()
-
- # check if extracted body is empty dispite having a text/html body part
- if eml is not None:
- bodypart = eml.get_body()
- if (bodypart and
- bodypart.get_payload() and
- eml.get_content_type() == 'text/html' and
- not bodytext):
- bodytext = MISSING_HTML_MSG
- return bodytext
-
def get_body_text(self):
+ """ returns bodystring extracted from this mail """
+ # TODO: allow toggle commands to decide which part is considered body
return extract_body(self.get_email())
def matches(self, querystring):
diff --git a/alot/db/utils.py b/alot/db/utils.py
index 3de39d3a..99b07b0b 100644
--- a/alot/db/utils.py
+++ b/alot/db/utils.py
@@ -458,6 +458,12 @@ def remove_cte(part, as_string=False):
return bp
+MISSING_HTML_MSG = ("This message contains a text/html part that was not "
+ "rendered due to a missing mailcap entry. "
+ "Please refer to item 5 in our FAQ: "
+ "http://alot.rtfd.io/en/latest/faq.html")
+
+
def extract_body(mail):
"""Returns a string view of a Message.
@@ -488,6 +494,9 @@ def extract_body(mail):
rendered_payload = render_part(body_part)
if rendered_payload: # handler had output
displaystring = string_sanitize(rendered_payload)
+ else:
+ if body_part.get_content_type() == 'text/html':
+ displaystring = MISSING_HTML_MSG
return displaystring
diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py
index ce35b480..0085ad34 100644
--- a/alot/widgets/thread.py
+++ b/alot/widgets/thread.py
@@ -251,7 +251,7 @@ class MessageTree(CollapsibleTree):
def _get_body(self):
if self._bodytree is None:
- bodytxt = self._message.accumulate_body()
+ bodytxt = self._message.get_body_text()
if bodytxt:
att = settings.get_theming_attribute('thread', 'body')
att_focus = settings.get_theming_attribute(