1
0
Fork 0
mirror of https://git.sr.ht/~rjarry/aerc synced 2025-07-16 00:13:50 +02:00
aerc/lib/send/jmap.go
Robin Jarry 553fabbc2e jmap: handle copy-to and :send -t
The jmap:// outgoing backend always copies (actually, just tags) the
sent emails with the mailbox that has the "sent" role. Regardless of the
copy-to or :send -t <folder> argument. Only the copy-to-replied setting
is effective.

Change the CopyTo parameter of the StartSendingMessage backend operation
to hold a list of folder names.

In the JMAP worker, label the sent message with the list of folders,
eliminating duplicates (e.g. do not label with "sent" role twice).

Reported-by: Matěj Cepl <mcepl@cepl.eu>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Matěj Cepl <mcepl@cepl.eu>
2024-12-21 17:02:31 +01:00

41 lines
808 B
Go

package send
import (
"fmt"
"io"
"github.com/emersion/go-message/mail"
"git.sr.ht/~rjarry/aerc/worker/types"
)
func newJmapSender(
worker *types.Worker, from *mail.Address, rcpts []*mail.Address,
copyTo []string,
) (io.WriteCloser, error) {
var writer io.WriteCloser
done := make(chan error)
worker.PostAction(
&types.StartSendingMessage{From: from, Rcpts: rcpts, CopyTo: copyTo},
func(msg types.WorkerMessage) {
switch msg := msg.(type) {
case *types.Done:
return
case *types.Unsupported:
done <- fmt.Errorf("unsupported by worker")
case *types.Error:
done <- msg.Error
case *types.MessageWriter:
writer = msg.Writer
default:
done <- fmt.Errorf("unexpected worker message: %#v", msg)
}
close(done)
},
)
err := <-done
return writer, err
}