summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-05-13 10:12:48 +0200
committerAnton Khirnov <anton@khirnov.net>2021-05-13 11:41:14 +0200
commit28fafa0ff9e7967059b4e310d61bf903af4834ff (patch)
tree6a1267a369b976c2f81010386aab9d60d022cd93
parenteef2d7d1521c88b689794a0bceedc40e93711a3e (diff)
commands/thread:ReplyCommand: use the message headers object in determine_sender()
-rw-r--r--alot/commands/thread.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 7d2180a6..bc41bdc4 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -68,13 +68,13 @@ def clear_my_address(my_account, value):
new_value.append(formataddr((name, address)))
return new_value
-def determine_sender(mail, action='reply'):
+def determine_sender(headers, action='reply'):
"""
Inspect a given mail to reply/forward/bounce and find the most appropriate
account to act from and construct a suitable From-Header to use.
- :param mail: the email to inspect
- :type mail: `email.message.Message`
+ :param headers: headers of the email to inspect
+ :type headers: `db.message._MessageHeaders`
:param action: intended use case: one of "reply", "forward" or "bounce"
:type action: str
"""
@@ -92,7 +92,7 @@ def determine_sender(mail, action='reply'):
# account X is the one selected and not account Y.
candidate_headers = settings.get("reply_account_header_priority")
for candidate_header in candidate_headers:
- candidate_addresses = getaddresses(mail.get_all(candidate_header, []))
+ candidate_addresses = getaddresses(headers.get_all(candidate_header))
logging.debug('candidate addresses: %s', candidate_addresses)
# pick the most important account that has an address in candidates
@@ -200,7 +200,7 @@ class ReplyCommand(Command):
# set From-header and sending account
try:
- from_header, account = determine_sender(mail, 'reply')
+ from_header, account = determine_sender(message.headers, 'reply')
except AssertionError as e:
ui.notify(str(e), priority='error')
return
@@ -374,7 +374,7 @@ class ForwardCommand(Command):
# set From-header and sending account
try:
- from_header, account = determine_sender(mail, 'reply')
+ from_header, account = determine_sender(message.headers, 'reply')
except AssertionError as e:
ui.notify(str(e), priority='error')
return
@@ -412,7 +412,7 @@ class BounceMailCommand(Command):
# set Resent-From-header and sending account
try:
- resent_from_header, account = determine_sender(mail, 'bounce')
+ resent_from_header, account = determine_sender(message.headers, 'bounce')
except AssertionError as e:
ui.notify(str(e), priority='error')
return