2019-05-14 22:34:42 +02:00
|
|
|
package imap
|
|
|
|
|
|
|
|
import (
|
2019-05-16 01:41:21 +02:00
|
|
|
"io"
|
|
|
|
|
2021-11-05 10:19:46 +01:00
|
|
|
"git.sr.ht/~rjarry/aerc/worker/types"
|
2019-05-14 22:34:42 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func (imapw *IMAPWorker) handleCopyMessages(msg *types.CopyMessages) {
|
2019-07-08 04:43:57 +02:00
|
|
|
uids := toSeqSet(msg.Uids)
|
|
|
|
if err := imapw.client.UidCopy(uids, msg.Destination); err != nil {
|
2019-05-14 22:34:42 +02:00
|
|
|
imapw.worker.PostMessage(&types.Error{
|
|
|
|
Message: types.RespondTo(msg),
|
|
|
|
Error: err,
|
|
|
|
}, nil)
|
|
|
|
} else {
|
2022-06-02 02:24:53 +02:00
|
|
|
imapw.worker.PostMessage(&types.MessagesCopied{
|
|
|
|
Message: types.RespondTo(msg),
|
|
|
|
Destination: msg.Destination,
|
|
|
|
Uids: msg.Uids,
|
|
|
|
}, nil)
|
2022-03-18 09:53:02 +01:00
|
|
|
imapw.worker.PostMessage(&types.Done{Message: types.RespondTo(msg)}, nil)
|
2019-05-14 22:34:42 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-16 01:41:21 +02:00
|
|
|
|
|
|
|
type appendLiteral struct {
|
|
|
|
io.Reader
|
|
|
|
Length int
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m appendLiteral) Len() int {
|
|
|
|
return m.Length
|
|
|
|
}
|
|
|
|
|
|
|
|
func (imapw *IMAPWorker) handleAppendMessage(msg *types.AppendMessage) {
|
2020-03-03 14:45:06 +01:00
|
|
|
if err := imapw.client.Append(msg.Destination, translateFlags(msg.Flags), msg.Date,
|
2019-05-16 01:41:21 +02:00
|
|
|
&appendLiteral{
|
|
|
|
Reader: msg.Reader,
|
|
|
|
Length: msg.Length,
|
|
|
|
}); err != nil {
|
|
|
|
|
|
|
|
imapw.worker.PostMessage(&types.Error{
|
|
|
|
Message: types.RespondTo(msg),
|
|
|
|
Error: err,
|
|
|
|
}, nil)
|
|
|
|
} else {
|
2022-03-18 09:53:02 +01:00
|
|
|
imapw.worker.PostMessage(&types.Done{Message: types.RespondTo(msg)}, nil)
|
2019-05-16 01:41:21 +02:00
|
|
|
}
|
|
|
|
}
|