summary refs log tree commit diff stats
path: root/worker/imap
diff options
context:
space:
mode:
Diffstat (limited to 'worker/imap')
-rw-r--r--worker/imap/remove.go19
-rw-r--r--worker/imap/worker.go2
2 files changed, 21 insertions, 0 deletions
diff --git a/worker/imap/remove.go b/worker/imap/remove.go
new file mode 100644
index 0000000..47b1f43
--- /dev/null
+++ b/worker/imap/remove.go
@@ -0,0 +1,19 @@
+package imap
+
+import (
+	"git.sr.ht/~sircmpwn/aerc/worker/types"
+)
+
+func (imapw *IMAPWorker) handleRemoveDirectory(msg *types.RemoveDirectory) {
+	if err := imapw.client.Delete(msg.Directory); err != nil {
+		if msg.Quiet {
+			return
+		}
+		imapw.worker.PostMessage(&types.Error{
+			Message: types.RespondTo(msg),
+			Error:   err,
+		}, nil)
+	} else {
+		imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
+	}
+}
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index 0be51d7..c016af6 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -165,6 +165,8 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {
 		w.handleFetchDirectoryContents(msg)
 	case *types.CreateDirectory:
 		w.handleCreateDirectory(msg)
+	case *types.RemoveDirectory:
+		w.handleRemoveDirectory(msg)
 	case *types.FetchMessageHeaders:
 		w.handleFetchMessageHeaders(msg)
 	case *types.FetchMessageBodyPart: