From 7b4e2cb0fddc1f38bf64be12a4cd812c08c30a19 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 13 May 2021 10:12:48 +0200 Subject: commands/thread:ReplyCommand: factor out list-reply logic --- alot/commands/thread.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/alot/commands/thread.py b/alot/commands/thread.py index 39a78618..64b84bdb 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -149,7 +149,7 @@ class ReplyCommand(Command): :type spawn: bool """ self.groupreply = all - self.listreply = listreply + self._force_list_reply = listreply self.force_spawn = spawn super().__init__(**kwargs) @@ -165,6 +165,18 @@ class ReplyCommand(Command): return subject + def _list_reply(self, message): + # Auto-detect ML + auto_replyto_mailinglist = settings.get('auto_replyto_mailinglist') + if 'List-Id' in message.headers and self._force_list_reply is None: + # mail['List-Id'] is need to enable reply-to-list + return auto_replyto_mailinglist + elif 'List-Id' in message.headers and self._force_list_reply is True: + return True + elif self._force_list_reply is False: + # In this case we only need the sender + return False + async def apply(self, ui): message = ui.current_buffer.get_selected_message() mail = message.get_email() @@ -191,17 +203,6 @@ class ReplyCommand(Command): envelope.add('Subject', self._reply_subject(message)) - # Auto-detect ML - auto_replyto_mailinglist = settings.get('auto_replyto_mailinglist') - if 'List-Id' in message.headers and self.listreply is None: - # mail['List-Id'] is need to enable reply-to-list - self.listreply = auto_replyto_mailinglist - elif 'List-Id' in message.headers and self.listreply is True: - self.listreply = True - elif self.listreply is False: - # In this case we only need the sender - self.listreply = False - # set From-header and sending account try: from_header, account = determine_sender(mail, 'reply') @@ -252,7 +253,7 @@ class ReplyCommand(Command): to = ', '.join(ensure_unique_address(recipients)) logging.debug('reply to: %s', to) - if self.listreply: + if self._list_reply(message): # To choose the target of the reply --list # Reply-To is standart reply target RFC 2822:, RFC 1036: 2.2.1 # X-BeenThere is needed by sourceforge ML also winehq -- cgit v1.2.3