summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-11-20 16:13:43 +0100
committerAnton Khirnov <anton@khirnov.net>2021-11-20 16:13:43 +0100
commit6a0ba55dc339b67afa363771525110c575fe6f62 (patch)
treecf159b8d7a7b4bcdc576a253e08a054be8dc8cd7
parentf5f723eada40036f74a022c2d9c7b6ac51efb63a (diff)
commands/thread: refactor adding mail-followup-to header
Move it to a separate function, simplify flow control.
-rw-r--r--alot/commands/thread.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index cba0af65..400d4774 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -185,6 +185,18 @@ class ReplyCommand(Command):
references.append('<%s>' % message.id)
return ' '.join(references)
+ def _mail_followup_to(self, recipients):
+ if not settings.get('followup_to'):
+ return None
+
+ lists = settings.get('mailinglists')
+
+ # check if any recipient address matches a known mailing list
+ if any(addr in lists for n, addr in getaddresses(recipients)):
+ followupto = ', '.join(recipients)
+ logging.debug('mail followup to: %s', followupto)
+ return followupto
+
async def apply(self, ui):
message = ui.current_buffer.get_selected_message()
@@ -280,22 +292,17 @@ class ReplyCommand(Command):
# Finally setup the 'To' header
headers[HDR.TO] = to
- # if any of the recipients is a mailinglist that we are subscribed to,
- # set Mail-Followup-To header so that duplicates are avoided
- if settings.get('followup_to'):
- # to and cc are already cleared of our own address
- allrecipients = [to] + cc
- lists = settings.get('mailinglists')
- # check if any recipient address matches a known mailing list
- if any(addr in lists for n, addr in getaddresses(allrecipients)):
- followupto = ', '.join(allrecipients)
- logging.debug('mail followup to: %s', followupto)
- headers[HDR.MAIL_FOLLOWUP_TO] = followupto
-
# set In-Reply-To + References headers
headers[HDR.IN_REPLY_TO] = '<%s>' % message.id
headers[HDR.REFERENCES] = self._reply_references(message)
+ # if any of the recipients is a mailinglist that we are subscribed to,
+ # set Mail-Followup-To header so that duplicates are avoided
+ # to and cc are already cleared of our own address
+ mft = self._mail_followup_to([to] + cc)
+ if mft:
+ headers[HDR.MAIL_FOLLOWUP_TO] = mft
+
# construct the envelope
envelope = Envelope(headers = headers, bodytext = mailcontent,
account = account, replied = message)