aboutsummaryrefslogtreecommitdiffstats
path: root/worker/mbox/worker.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-08-16 16:23:38 -0500
committerRobin Jarry <robin@jarry.cc>2022-08-22 15:46:52 +0200
commit57933f65ab456fc4ac81423422b6686801e08c9e (patch)
tree10224a575ed858166f8aa584e4b1be63a226b095 /worker/mbox/worker.go
parente8c5bb641a9f31979bebf0f827befcfb4456bb9d (diff)
downloadaerc-57933f65ab456fc4ac81423422b6686801e08c9e.tar.gz
mbox: implement MoveMessages handling
Implement MoveMessages handling in the mbox backend. The mbox backend exists entirely in memory, so the handling is equivalent to a copy-and-delete. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/mbox/worker.go')
-rw-r--r--worker/mbox/worker.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/worker/mbox/worker.go b/worker/mbox/worker.go
index 71da8161..067147e0 100644
--- a/worker/mbox/worker.go
+++ b/worker/mbox/worker.go
@@ -295,6 +295,24 @@ func (w *mboxWorker) handleMessage(msg types.WorkerMessage) error {
w.worker.PostMessage(
&types.Done{Message: types.RespondTo(msg)}, nil)
+ case *types.MoveMessages:
+ err := w.data.Copy(msg.Destination, w.name, msg.Uids)
+ if err != nil {
+ reterr = err
+ break
+ }
+ deleted := w.folder.Delete(msg.Uids)
+ if len(deleted) > 0 {
+ w.worker.PostMessage(&types.MessagesDeleted{
+ Message: types.RespondTo(msg),
+ Uids: deleted,
+ }, nil)
+ }
+ w.worker.PostMessage(&types.DirectoryInfo{
+ Info: w.data.DirectoryInfo(msg.Destination),
+ }, nil)
+ w.worker.PostMessage(
+ &types.Done{Message: types.RespondTo(msg)}, nil)
case *types.SearchDirectory:
uids, err := filterUids(w.folder, w.folder.Uids(), msg.Argv)