From 8bc3ccb9017b04aafccafa294f219ced5b41a372 Mon Sep 17 00:00:00 2001 From: Kevin Kuehler Date: Mon, 28 Oct 2019 12:07:07 -0700 Subject: Add manual threading to the pipeline Signed-off-by: Kevin Kuehler --- worker/imap/open.go | 17 +++++++++++++++++ worker/imap/worker.go | 2 ++ worker/types/messages.go | 9 +++++++++ 3 files changed, 28 insertions(+) (limited to 'worker') diff --git a/worker/imap/open.go b/worker/imap/open.go index 1152887..c7a479a 100644 --- a/worker/imap/open.go +++ b/worker/imap/open.go @@ -50,6 +50,23 @@ func (imapw *IMAPWorker) handleFetchDirectoryContents( } } +func (imapw *IMAPWorker) handleNativeThreadSupport( + msg *types.FetchNativeThreadSupport) { + hasSupport, err := imapw.client.tc.SupportThread() + if err != nil { + imapw.worker.PostMessage(&types.Error{ + Message: types.RespondTo(msg), + Error: err, + }, nil) + } else { + imapw.worker.PostMessage(&types.NativeThreadSupport{ + Message: types.RespondTo(msg), + HasSupport: hasSupport, + }, nil) + imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil) + } +} + func (imapw *IMAPWorker) handleDirectoryThreaded( msg *types.FetchDirectoryThreaded) { imapw.worker.Logger.Printf("Fetching threaded UID list") diff --git a/worker/imap/worker.go b/worker/imap/worker.go index 1ba3774..ed1ad9e 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.FetchDirectoryThreaded: w.handleDirectoryThreaded(msg) + case *types.FetchNativeThreadSupport: + w.handleNativeThreadSupport(msg) case *types.CreateDirectory: w.handleCreateDirectory(msg) case *types.FetchMessageHeaders: diff --git a/worker/types/messages.go b/worker/types/messages.go index d5f2484..2cde38f 100644 --- a/worker/types/messages.go +++ b/worker/types/messages.go @@ -81,6 +81,10 @@ type FetchDirectoryContents struct { SortCriteria []*SortCriterion } +type FetchNativeThreadSupport struct { + Message +} + type FetchDirectoryThreaded struct { Message SortCriteria []*SortCriterion @@ -157,6 +161,11 @@ type DirectoryContents struct { Uids []uint32 } +type NativeThreadSupport struct { + Message + HasSupport bool +} + type DirectoryThreaded struct { Message ThreadRoot *Thread -- cgit v1.2.3