From 32b9653ea705d512614b351da7bae95773e7eb6e Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 28 Nov 2022 21:15:36 -0600 Subject: imap: check for list-status capability Check for LIST-STATUS capability on IMAP servers. This will be used in subsequent commits for improved check-mail performance. The LIST-STATUS command allows the LIST command to also return STATUS responses, which include message counts. Upgrade go-imap to latest release. Add go-imap-liststatus extension. Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- worker/imap/worker.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'worker') diff --git a/worker/imap/worker.go b/worker/imap/worker.go index 32e05859..752eac52 100644 --- a/worker/imap/worker.go +++ b/worker/imap/worker.go @@ -15,6 +15,7 @@ import ( "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/worker/handlers" + "git.sr.ht/~rjarry/aerc/worker/imap/extensions" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -32,8 +33,9 @@ var ( type imapClient struct { *client.Client - thread *sortthread.ThreadClient - sort *sortthread.SortClient + thread *sortthread.ThreadClient + sort *sortthread.SortClient + liststatus *extensions.ListStatusClient } type imapConfig struct { @@ -72,6 +74,7 @@ type IMAPWorker struct { caps *models.Capabilities threadAlgorithm sortthread.ThreadAlgorithm + liststatus bool } func NewIMAPWorker(worker *types.Worker) (types.Backend, error) { @@ -87,7 +90,12 @@ func NewIMAPWorker(worker *types.Worker) (types.Backend, error) { func (w *IMAPWorker) newClient(c *client.Client) { c.Updates = w.updates - w.client = &imapClient{c, sortthread.NewThreadClient(c), sortthread.NewSortClient(c)} + w.client = &imapClient{ + c, + sortthread.NewThreadClient(c), + sortthread.NewSortClient(c), + extensions.NewListStatusClient(c), + } w.idler.SetClient(w.client) w.observer.SetClient(w.client) sort, err := w.client.sort.SupportSort() @@ -104,6 +112,11 @@ func (w *IMAPWorker) newClient(c *client.Client) { break } } + lStatus, err := w.client.liststatus.SupportListStatus() + if err == nil && lStatus { + w.liststatus = true + log.Debugf("Server Capability found: LIST-STATUS") + } } func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error { -- cgit