aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap/worker.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-07-16 17:04:14 +0200
committerRobin Jarry <robin@jarry.cc>2023-08-03 22:29:18 +0200
commit0e09c05937913a938bc4987db2b6d193ed0501bd (patch)
tree34a54eb15b3bbc2ff507671c7b28f8943cac73df /worker/imap/worker.go
parent2fbce2e2c9aa782cc3d99a7232d78876b835e513 (diff)
downloadaerc-0e09c05937913a938bc4987db2b6d193ed0501bd.tar.gz
imap: support the Gmail extension (X-GM-EXT-1)
Support the IMAP Gmail extension (X-GM-EXT-1) to fetch all messages for a given thread. This allows client-side threading to display a full message thread. Obviously, it requires a Gmail account to work. The extension is only used when requested in accounts.conf with: "use-gmail-ext = true" (default: false) Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Tristan Partin <tristan@partin.io>
Diffstat (limited to 'worker/imap/worker.go')
-rw-r--r--worker/imap/worker.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index f08c0ec9..7ef759d4 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -15,6 +15,7 @@ import (
"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/middleware"
"git.sr.ht/~rjarry/aerc/worker/types"
)
@@ -58,6 +59,7 @@ type imapConfig struct {
keepalive_interval int
cacheEnabled bool
cacheMaxAge time.Duration
+ useXGMEXT bool
}
type IMAPWorker struct {
@@ -120,6 +122,14 @@ func (w *IMAPWorker) newClient(c *client.Client) {
w.liststatus = true
w.worker.Debugf("Server Capability found: LIST-STATUS")
}
+ xgmext, err := w.client.Support("X-GM-EXT-1")
+ if err == nil && xgmext && w.config.useXGMEXT {
+ w.worker.Debugf("Server Capability found: X-GM-EXT-1")
+ w.worker = middleware.NewGmailWorker(w.worker, w.client.Client, w.idler)
+ }
+ if err == nil && !xgmext && w.config.useXGMEXT {
+ w.worker.Infof("X-GM-EXT-1 requested, but it is not supported")
+ }
}
func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {