From 28fafa0ff9e7967059b4e310d61bf903af4834ff Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 13 May 2021 10:12:48 +0200 Subject: commands/thread:ReplyCommand: use the message headers object in determine_sender() --- alot/commands/thread.py | 14 +++++++------- 1 file 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 -- cgit v1.2.3