From 14848152ffa713811f94b8aa43cabadd0410ecd5 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Wed, 25 Nov 2020 16:10:27 -0500 Subject: Use both To: and Cc: for --cc-trailers There doesn't seem to be much rhyme or reason for why an address would be in "To" or "Cc", so use both headers when finding Cc: trailer recipients. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index 86991e3..3deed18 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -1305,10 +1305,11 @@ class LoreMessage: trailers = btrailers + self.followup_trailers if copyccs: - allccs = email.utils.getaddresses([str(x) for x in self.msg.get_all('cc', [])]) + alldests = email.utils.getaddresses([str(x) for x in self.msg.get_all('to', [])]) + alldests += email.utils.getaddresses([str(x) for x in self.msg.get_all('cc', [])]) # Sort by domain name, then local - allccs.sort(key=lambda x: x[1].find('@') > 0 and x[1].split('@')[1] + x[1].split('@')[0] or x[1]) - for pair in allccs: + alldests.sort(key=lambda x: x[1].find('@') > 0 and x[1].split('@')[1] + x[1].split('@')[0] or x[1]) + for pair in alldests: found = False for ftr in trailers: if ftr[1].lower().find(pair[1].lower()) >= 0: -- cgit v1.2.3