summaryrefslogtreecommitdiff
path: root/alot/widgets
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-03-06 09:10:29 +0100
committerAnton Khirnov <anton@khirnov.net>2020-03-06 09:13:30 +0100
commitd70f627c7a91e0aeed60c29e690be300c4008dab (patch)
treef6c7cedc87e60caf2d295598e6c92fe76a7f44aa /alot/widgets
parente2efd81f0dc4f913c73a2494091f67c748001942 (diff)
widgets/thread: use the headers object to access message headers
Avoid accessing the email directly.
Diffstat (limited to 'alot/widgets')
-rw-r--r--alot/widgets/thread.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py
index f6a0a9ea..dcbbd9da 100644
--- a/alot/widgets/thread.py
+++ b/alot/widgets/thread.py
@@ -56,9 +56,7 @@ class MessageSummaryWidget(urwid.WidgetWrap):
super().__init__(line)
def __str__(self):
- mail = self.message.get_email()
-
- subj = mail.get_all('subject', [''])
+ subj = self.message.headers['Subject']
subj = re.sub(r'\n\s+', r' ', ','.join(subj))
author, address = self.message.get_author()
@@ -245,21 +243,21 @@ class MessageWidget(urwid.WidgetWrap):
if val == self._display_all_headers:
return
- mail = self._message.get_email()
+ headers = self._message.headers
lines = []
if val:
# collect all header/value pairs in the order they appear
- lines = list(mail.items())
+ lines = list(headers.items())
else:
# only a selection of headers should be displayed.
# use order of the `headers` parameter
for key in settings.get('displayed_headers'):
- if key in mail:
+ if key in headers:
if key.lower() in ['cc', 'bcc', 'to']:
- lines.append((key, ', '.join(mail.get_all(key))))
+ lines.append((key, ', '.join(headers[key])))
else:
- for value in mail.get_all(key):
+ for value in headers[key]:
lines.append((key, value))
elif key.lower() == 'tags':
# TODO this should be in a separate widget
@@ -274,8 +272,8 @@ class MessageWidget(urwid.WidgetWrap):
# OpenPGP pseudo headers
# TODO this should be in a separate widget
- if mail[X_SIGNATURE_MESSAGE_HEADER]:
- lines.append(('PGP-Signature', mail[X_SIGNATURE_MESSAGE_HEADER]))
+ if X_SIGNATURE_MESSAGE_HEADER in headers:
+ lines.append(('PGP-Signature', headers[X_SIGNATURE_MESSAGE_HEADER][0]))
self._headers_wgt.set_headers(lines)