summaryrefslogtreecommitdiff
path: root/alot/db/message.py
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-11-24 15:02:13 +0100
committerAnton Khirnov <anton@khirnov.net>2021-11-24 15:02:13 +0100
commit4ea9cd3cb2b56aa3bc349f327108d552ad2e2b73 (patch)
treeeb17015decb75cc9bbd51cdb9ffc1927fe5347cb /alot/db/message.py
parentd4884172803b8c0aa730050e9742087d8315066f (diff)
mail/reply: rewrite recipient selection
Thoroughly ensure that To+Cc contains neither our own address (except when it is wanted) nor any duplicates. Use structured headers provided by email.headerregistry to simplify dealing with addr-spec vs. mailbox (display name + <addr-spec>).
Diffstat (limited to 'alot/db/message.py')
-rw-r--r--alot/db/message.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/alot/db/message.py b/alot/db/message.py
index 97ab991f..01d7c7f1 100644
--- a/alot/db/message.py
+++ b/alot/db/message.py
@@ -119,6 +119,20 @@ class _MessageHeaders:
return []
raise
+ def pick_addrlist_header(self, *args):
+ """
+ Given a list of "address-list" header names as positional arguments,
+ return the addresses from the first one that is present.
+
+ :returns: addresses from the first existing header, or an empty tuple
+ :rtype: tuple(headerregistry.Address)
+ """
+ for h in args:
+ if h in self:
+ return self.get(h).addresses
+
+ return ()
+
class _MimeTree:
_part = None