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 10:37:25 +0200
commit7b4e2cb0fddc1f38bf64be12a4cd812c08c30a19 (patch)
treec98cf83762d9394c7def94b729cf565063311954
parent9ffd58ba4e3f167ce521c3269649b5705e7c280c (diff)
commands/thread:ReplyCommand: factor out list-reply logic
-rw-r--r--alot/commands/thread.py27
1 files 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