diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-07-05 14:48:37 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-07-10 21:15:12 +0200 |
commit | f0c76fad7299c2c43f5891becd4f0327e0e26df5 (patch) | |
tree | 360de71aa1cef4f2c84cc0014aa86dffffd34e4b /worker/imap | |
parent | a8879d79c67f2631388e244548f7499b367e93ce (diff) | |
download | aerc-f0c76fad7299c2c43f5891becd4f0327e0e26df5.tar.gz |
threading: add backend capabilities to workers
This patch provides a method to report backend capabilities to the UI.
The intial capabilities included in the report are Sort and Thread.
Having these available to the UI enables the client to better handle
server side threading.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/imap')
-rw-r--r-- | worker/imap/checkmail.go | 1 | ||||
-rw-r--r-- | worker/imap/worker.go | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/worker/imap/checkmail.go b/worker/imap/checkmail.go index d9dcfd33..57af3af5 100644 --- a/worker/imap/checkmail.go +++ b/worker/imap/checkmail.go @@ -31,6 +31,7 @@ func (w *IMAPWorker) handleCheckMailMessage(msg *types.CheckMail) { Exists: int(status.Messages), Recent: int(status.Recent), Unseen: int(status.Unseen), + Caps: w.caps, }, SkipSort: true, }, nil) diff --git a/worker/imap/worker.go b/worker/imap/worker.go index 7debd883..3ed646df 100644 --- a/worker/imap/worker.go +++ b/worker/imap/worker.go @@ -66,6 +66,8 @@ type IMAPWorker struct { idler *idler observer *observer cache *leveldb.DB + + caps *models.Capabilities } func NewIMAPWorker(worker *types.Worker) (types.Backend, error) { @@ -75,6 +77,7 @@ func NewIMAPWorker(worker *types.Worker) (types.Backend, error) { selected: &imap.MailboxStatus{}, idler: newIdler(imapConfig{}, worker), observer: newObserver(imapConfig{}, worker), + caps: &models.Capabilities{}, }, nil } @@ -83,6 +86,16 @@ func (w *IMAPWorker) newClient(c *client.Client) { w.client = &imapClient{c, sortthread.NewThreadClient(c), sortthread.NewSortClient(c)} w.idler.SetClient(w.client) w.observer.SetClient(w.client) + sort, err := w.client.sort.SupportSort() + if err == nil && sort { + w.caps.Sort = true + w.worker.Logger.Println("Server Capability found: Sort") + } + thread, err := w.client.thread.SupportThread() + if err == nil && thread { + w.caps.Thread = true + w.worker.Logger.Println("Server Capability found: Thread") + } } func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error { @@ -226,6 +239,7 @@ func (w *IMAPWorker) handleImapUpdate(update client.Update) { Exists: int(status.Messages), Recent: int(status.Recent), Unseen: int(status.Unseen), + Caps: w.caps, }, }, nil) case *client.MessageUpdate: |