msg/reply: Deduplicate TO: and CC:
If a recipient is already in TO:, there's no need to also put them in CC:
This commit is contained in:
parent
d1600e4666
commit
8f2e5055ee
1 changed files with 12 additions and 0 deletions
|
@ -89,8 +89,20 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
to = append(to, fmt.Sprintf("<%s@%s>", addr.Mailbox, addr.Host))
|
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 {
|
if replyAll {
|
||||||
for _, addr := range msg.Envelope.Cc {
|
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())
|
cc = append(cc, addr.Format())
|
||||||
}
|
}
|
||||||
for _, addr := range msg.Envelope.To {
|
for _, addr := range msg.Envelope.To {
|
||||||
|
|
Loading…
Reference in a new issue