aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-05-04 19:17:23 +0200
committerDrew DeVault <sir@cmpwn.com>2020-05-06 10:00:36 -0400
commit8f2e5055eeb7e8058b637ab6cff6ff5f44da487b (patch)
tree61a743aba3aaf05b3d73f53caabef485a5710b99 /commands/msg
parentd1600e4666e9efdb3ae45ef2cc01182950a41bb5 (diff)
downloadaerc-8f2e5055eeb7e8058b637ab6cff6ff5f44da487b.tar.gz
msg/reply: Deduplicate TO: and CC:
If a recipient is already in TO:, there's no need to also put them in CC:
Diffstat (limited to 'commands/msg')
-rw-r--r--commands/msg/reply.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index 291fc4b7..74f00977 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -89,8 +89,20 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
to = append(to, fmt.Sprintf("<%s@%s>", addr.Mailbox, addr.Host))
}
}
+ isMainRecipient := func(a *models.Address) bool {
+ for _, ta := range toList {
+ if ta.Mailbox == a.Mailbox && ta.Host == a.Host {
+ return true
+ }
+ }
+ return false
+ }
if replyAll {
for _, addr := range msg.Envelope.Cc {
+ //dedupe stuff already in the to: header, no need to repeat
+ if isMainRecipient(addr) {
+ continue
+ }
cc = append(cc, addr.Format())
}
for _, addr := range msg.Envelope.To {