imap: honor reply-to-self when replying to all

The reply-to-self configuration is not always properly honored when
replying to all, due to a bug in reply.Execute's dedupe logic.

It uses a map to keep track of the addresses it has already seen, and
exclude them from the lists subsequently passed to "dedupe".

Since we use "dedupe" to build the reply's From, our address is excluded
when building the To/Cc, even if reply-to-self is true. This patch fixes
this by making sure that our address is *not* part of the exclude list
before building the reply's To/Cc.

Basic logs showing the behaviour with and without this patch can be
found here:
  https://paste.sr.ht/~simartin/e502022d06f8a3d8f827179f28d89165545af67f

Signed-off-by: Simon Martin <simon@nasilyan.com>
Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Simon Martin
2025-03-14 11:20:20 +01:00
committed by Robin Jarry
parent 96ccb183fb
commit 063c19b619

View File

@@ -130,8 +130,12 @@ func (r reply) Execute(args []string) error {
// order matters, due to the deduping
// in order of importance, first parse the To, then the Cc header
// we add our from address, so that we don't self address ourselves
recSet.Add(from)
// If we accept to reply to ourselves, remove our address from recSet.
// This will ensure that we are at least once in the reply's recipients
// if we were a recipient of the message we're replying to.
if config.Compose.ReplyToSelf {
delete(recSet, from.Address)
}
to = append(to, dedupe(msg.Envelope.To)...)