summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2017-01-22 17:35:47 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2017-01-22 17:51:51 +0000
commit2c85e7322f7a060309ee83e5906c731d3d8f5da6 (patch)
tree4546f8ff1cf71c0dc989edbb0019a51c09b0e59c
parentc950e1e65d9073dc54f5b78ec5af1396c81fd58b (diff)
make addresses unique in To headers
-rw-r--r--alot/commands/thread.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 95d8c93b..6dd4f248 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -231,7 +231,20 @@ class ReplyCommand(Command):
my_addresses, mail.get_all('Cc', []))
envelope.add('Cc', decode_header(', '.join(cc)))
- to = ', '.join(recipients)
+ def ensure_unique_address(recipients):
+ """
+ clean up a list of name,address pairs so that
+ no address appears multiple times.
+ """
+ res = dict()
+ for name, address in getaddresses(recipients):
+ res[address] = name
+ urecipients = ['"{}" <{}>'.format(n, a) if n != ''
+ else a
+ for a, n in res.iteritems()]
+ return sorted(urecipients)
+
+ to = ', '.join(ensure_unique_address(recipients))
logging.debug('reply to: %s', to)
if self.listreply:
@@ -295,7 +308,7 @@ class ReplyCommand(Command):
new_value.append('"%s" <%s>' % (name, address))
else:
new_value.append(address)
- return ', '.join(new_value)
+ return new_value
@registerCommand(MODE, 'forward', arguments=[