From 4ea9cd3cb2b56aa3bc349f327108d552ad2e2b73 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 24 Nov 2021 15:02:13 +0100 Subject: 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 + ). --- alot/db/message.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'alot/db/message.py') 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 -- cgit v1.2.3