about summary refs log tree commit diff stats
path: root/worker/imap/worker.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-01-13 16:18:10 -0500
committerDrew DeVault <sir@cmpwn.com>2019-01-13 16:18:10 -0500
commit2750f99a6049322b1361b5bfa4dff3b1df2b36ab (patch)
tree0c18f4a8180f1eda1616c07296d20323edfeab62 /worker/imap/worker.go
parentcf664620005cf65d060e689fbb27b939dd3192a7 (diff)
downloadaerc-2750f99a6049322b1361b5bfa4dff3b1df2b36ab.tar.gz
Issue IMAP SELECT command
Diffstat (limited to 'worker/imap/worker.go')
-rw-r--r--worker/imap/worker.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index d75dbb0..4381e22 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -149,12 +149,30 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {
 		w.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
 	case *types.ListDirectories:
 		w.handleListDirectories(msg)
+	case *types.OpenDirectory:
+		w.handleOpenDirectory(msg)
 	default:
 		return errUnsupported
 	}
 	return nil
 }
 
+func (w *IMAPWorker) handleImapUpdate(update client.Update) {
+	w.worker.Logger.Printf("(= %T", update)
+	switch update := update.(type) {
+	case *client.MailboxUpdate:
+		status := update.Mailbox
+		w.worker.PostMessage(&types.DirectoryInfo{
+			ReadOnly: status.ReadOnly,
+			Flags:    status.Flags,
+
+			Exists: int(status.Messages),
+			Recent: int(status.Recent),
+			Unseen: int(status.Unseen),
+		}, nil)
+	}
+}
+
 func (w *IMAPWorker) Run() {
 	for {
 		select {
@@ -171,7 +189,7 @@ func (w *IMAPWorker) Run() {
 				}, nil)
 			}
 		case update := <-w.updates:
-			w.worker.Logger.Printf("(= %T", update)
+			w.handleImapUpdate(update)
 		}
 	}
 }