aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap
diff options
context:
space:
mode:
Diffstat (limited to 'worker/imap')
-rw-r--r--worker/imap/cache.go9
-rw-r--r--worker/imap/configure.go2
-rw-r--r--worker/imap/fetch.go16
-rw-r--r--worker/imap/worker.go2
4 files changed, 25 insertions, 4 deletions
diff --git a/worker/imap/cache.go b/worker/imap/cache.go
index a02f2cae..cf372154 100644
--- a/worker/imap/cache.go
+++ b/worker/imap/cache.go
@@ -8,6 +8,7 @@ import (
"fmt"
"os"
"path"
+ "strings"
"time"
"git.sr.ht/~rjarry/aerc/lib/parse"
@@ -42,6 +43,14 @@ var (
// initCacheDb opens (or creates) the database for the cache. One database is
// created per account
func (w *IMAPWorker) initCacheDb(acct string) {
+ switch {
+ case len(w.config.headersExclude) > 0:
+ headerTag := strings.Join(w.config.headersExclude, "")
+ cacheTag = append(cacheTag, headerTag...)
+ case len(w.config.headers) > 0:
+ headerTag := strings.Join(w.config.headers, "")
+ cacheTag = append(cacheTag, headerTag...)
+ }
cd, err := cacheDir()
if err != nil {
w.cache = nil
diff --git a/worker/imap/configure.go b/worker/imap/configure.go
index a9689f68..1581794f 100644
--- a/worker/imap/configure.go
+++ b/worker/imap/configure.go
@@ -60,6 +60,8 @@ func (w *IMAPWorker) handleConfigure(msg *types.Configure) error {
w.config.user = u.User
w.config.folders = msg.Config.Folders
+ w.config.headers = msg.Config.Headers
+ w.config.headersExclude = msg.Config.HeadersExclude
w.config.idle_timeout = 10 * time.Second
w.config.idle_debounce = 10 * time.Millisecond
diff --git a/worker/imap/fetch.go b/worker/imap/fetch.go
index f209d7f0..8189e6aa 100644
--- a/worker/imap/fetch.go
+++ b/worker/imap/fetch.go
@@ -29,11 +29,19 @@ func (imapw *IMAPWorker) handleFetchMessageHeaders(
return
}
log.Tracef("Fetching message headers: %v", toFetch)
+ hdrBodyPart := imap.BodyPartName{
+ Specifier: imap.HeaderSpecifier,
+ }
+ switch {
+ case len(imapw.config.headersExclude) > 0:
+ hdrBodyPart.NotFields = true
+ hdrBodyPart.Fields = imapw.config.headersExclude
+ case len(imapw.config.headers) > 0:
+ hdrBodyPart.Fields = imapw.config.headers
+ }
section := &imap.BodySectionName{
- BodyPartName: imap.BodyPartName{
- Specifier: imap.HeaderSpecifier,
- },
- Peek: true,
+ BodyPartName: hdrBodyPart,
+ Peek: true,
}
items := []imap.FetchItem{
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index f9a722e6..f46f39d6 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -43,6 +43,8 @@ type imapConfig struct {
insecure bool
addr string
user *url.Userinfo
+ headers []string
+ headersExclude []string
folders []string
oauthBearer lib.OAuthBearer
xoauth2 lib.Xoauth2