aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjp39 <jp39@gmx.com>2022-11-08 10:52:12 +0100
committerRobin Jarry <robin@jarry.cc>2022-11-09 21:21:12 +0100
commite0d279d6128a22db56326557883ad790544bc4f7 (patch)
tree5bf50a203762e4edf22d6f20ac0fe4d923d7b130
parentc84d91ad9f36c601a938fcbc0ebc29eb9a0e13fc (diff)
downloadaerc-e0d279d6128a22db56326557883ad790544bc4f7.tar.gz
imap: add support for ORDEREDSUBJECT threading algorithm
The imap worker incorrectly tries to use the REFERENCES threading algorithm by default although some servers only support the ORDEREDSUBJECT threading algorithm. Use whichever threading algorithm is advertised as supported by the server, buf prefer REFERENCES if available. Signed-off-by: jp39 <jp39@gmx.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
-rw-r--r--worker/imap/open.go2
-rw-r--r--worker/imap/worker.go14
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
+ }
}
}