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