aboutsummaryrefslogtreecommitdiffstats
path: root/worker
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-11-28 21:15:36 -0600
committerRobin Jarry <robin@jarry.cc>2022-12-02 22:59:44 +0100
commit32b9653ea705d512614b351da7bae95773e7eb6e (patch)
tree7048c1e746dca999b969de3bb1e9648a9a7357d7 /worker
parenta92d0c4c2e6e2b997a2512a2773958b842ac230c (diff)
downloadaerc-32b9653ea705d512614b351da7bae95773e7eb6e.tar.gz
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 <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker')
-rw-r--r--worker/imap/worker.go19
1 files changed, 16 insertions, 3 deletions
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 {