diff options
Diffstat (limited to 'worker')
-rw-r--r-- | worker/imap/open.go | 2 | ||||
-rw-r--r-- | worker/imap/worker.go | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/worker/imap/open.go b/worker/imap/open.go index c734ba8b..f3f20a59 100644 --- a/worker/imap/open.go +++ b/worker/imap/open.go @@ -115,7 +115,7 @@ func (imapw *IMAPWorker) handleDirectoryThreaded( }, nil) return } - threads, err := imapw.client.thread.UidThread(sortthread.References, + threads, err := imapw.client.thread.UidThread(imapw.threadAlgorithm, searchCriteria) if err != nil { imapw.worker.PostMessage(&types.Error{ diff --git a/worker/imap/worker.go b/worker/imap/worker.go index c5032a0b..506eb182 100644 --- a/worker/imap/worker.go +++ b/worker/imap/worker.go @@ -70,6 +70,8 @@ type IMAPWorker struct { cache *leveldb.DB caps *models.Capabilities + + threadAlgorithm sortthread.ThreadAlgorithm } func NewIMAPWorker(worker *types.Worker) (types.Backend, error) { @@ -93,10 +95,14 @@ func (w *IMAPWorker) newClient(c *client.Client) { w.caps.Sort = true logging.Infof("Server Capability found: Sort") } - thread, err := w.client.thread.SupportThread() - if err == nil && thread { - w.caps.Thread = true - logging.Infof("Server Capability found: Thread") + for _, alg := range []sortthread.ThreadAlgorithm{sortthread.References, sortthread.OrderedSubject} { + ok, err := w.client.Support(fmt.Sprintf("THREAD=%s", string(alg))) + if err == nil && ok { + w.threadAlgorithm = alg + w.caps.Thread = true + logging.Infof("Server Capability found: Thread (algorithm: %s)", string(alg)) + break + } } } |