2019-05-14 16:34:42 -04:00
|
|
|
package imap
|
|
|
|
|
|
|
|
import (
|
2019-05-15 19:41:21 -04:00
|
|
|
"io"
|
|
|
|
|
2021-11-05 10:19:46 +01:00
|
|
|
"git.sr.ht/~rjarry/aerc/worker/types"
|
2019-05-14 16:34:42 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func (imapw *IMAPWorker) handleCopyMessages(msg *types.CopyMessages) {
|
2019-07-07 22:43:57 -04:00
|
|
|
uids := toSeqSet(msg.Uids)
|
|
|
|
if err := imapw.client.UidCopy(uids, msg.Destination); err != nil {
|
2019-05-14 16:34:42 -04:00
|
|
|
imapw.worker.PostMessage(&types.Error{
|
|
|
|
Message: types.RespondTo(msg),
|
|
|
|
Error: err,
|
|
|
|
}, nil)
|
|
|
|
} else {
|
2022-06-01 19:24:53 -05: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 16:34:42 -04:00
|
|
|
}
|
|
|
|
}
|
2019-05-15 19:41:21 -04: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 08:45:06 -05:00
|
|
|
if err := imapw.client.Append(msg.Destination, translateFlags(msg.Flags), msg.Date,
|
2019-05-15 19:41:21 -04: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-15 19:41:21 -04:00
|
|
|
}
|
|
|
|
}
|