From 8f2e5055eeb7e8058b637ab6cff6ff5f44da487b Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Mon, 4 May 2020 19:17:23 +0200 Subject: msg/reply: Deduplicate TO: and CC: If a recipient is already in TO:, there's no need to also put them in CC: --- commands/msg/reply.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'commands/msg') 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 { -- cgit