summary refs log tree commit diff stats
path: root/worker/imap
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-14 22:19:04 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-14 22:19:04 -0400
commitde364846ccaba3b93c383add3846443048f1c2c9 (patch)
treeffb160063d15d8d3b7e78520f71f09ea7fae6371 /worker/imap
parent11f0a7267fd1a9d1c6dd55e1dc044b8ed639bbc0 (diff)
downloadaerc-de364846ccaba3b93c383add3846443048f1c2c9.tar.gz
Display message subjects in message list
Diffstat (limited to 'worker/imap')
-rw-r--r--worker/imap/fetch.go46
-rw-r--r--worker/imap/worker.go2
2 files changed, 48 insertions, 0 deletions
diff --git a/worker/imap/fetch.go b/worker/imap/fetch.go
new file mode 100644
index 0000000..383a8a8
--- /dev/null
+++ b/worker/imap/fetch.go
@@ -0,0 +1,46 @@
+package imap
+
+import (
+	"github.com/emersion/go-imap"
+
+	"git.sr.ht/~sircmpwn/aerc2/worker/types"
+)
+
+func (imapw *IMAPWorker) handleFetchMessageHeaders(
+	msg *types.FetchMessageHeaders) {
+
+	imapw.worker.Logger.Printf("Fetching message headers")
+
+	go func() {
+		messages := make(chan *imap.Message)
+		done := make(chan error, 1)
+		items := []imap.FetchItem{
+			imap.FetchEnvelope,
+			imap.FetchInternalDate,
+			imap.FetchFlags,
+			imap.FetchUid,
+		}
+		go func() {
+			done <- imapw.client.UidFetch(&msg.Uids, items, messages)
+		}()
+		go func() {
+			for msg := range messages {
+				imapw.worker.PostMessage(&types.MessageInfo{
+					Envelope:     msg.Envelope,
+					Flags:        msg.Flags,
+					InternalDate: msg.InternalDate,
+					Uid:          msg.Uid,
+				}, nil)
+			}
+			if err := <-done; err != nil {
+				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 51cb221..1646165 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -154,6 +154,8 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {
 		w.handleOpenDirectory(msg)
 	case *types.FetchDirectoryContents:
 		w.handleFetchDirectoryContents(msg)
+	case *types.FetchMessageHeaders:
+		w.handleFetchMessageHeaders(msg)
 	default:
 		return errUnsupported
 	}
ir@cmpwn.com> 2019-03-17 17:08:54 -0400 committer Drew DeVault <sir@cmpwn.com> 2019-03-17 17:08:54 -0400 Handle terminal title, login shell' href='/akspecs/aerc/commit/go.mod?h=0.5.0&id=16c3f0a89309541e36a2de22e91176fd13c67898'>16c3f0a ^
072bc26 ^
8d20e92 ^
072bc26 ^


3836d24 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25