aboutsummaryrefslogtreecommitdiffstats
path: root/worker
diff options
context:
space:
mode:
Diffstat (limited to 'worker')
-rw-r--r--worker/imap/configure.go22
-rw-r--r--worker/imap/idler.go4
-rw-r--r--worker/imap/observer.go4
-rw-r--r--worker/imap/worker.go2
4 files changed, 27 insertions, 5 deletions
diff --git a/worker/imap/configure.go b/worker/imap/configure.go
index 783485a7..94b5ac60 100644
--- a/worker/imap/configure.go
+++ b/worker/imap/configure.go
@@ -1,13 +1,18 @@
package imap
import (
+ "bufio"
"fmt"
"net/url"
+ "os"
"strconv"
"strings"
"time"
+ "git.sr.ht/~rjarry/aerc/worker/lib"
+ "git.sr.ht/~rjarry/aerc/worker/middleware"
"git.sr.ht/~rjarry/aerc/worker/types"
+ "github.com/mitchellh/go-homedir"
"golang.org/x/oauth2"
)
@@ -158,5 +163,22 @@ func (w *IMAPWorker) handleConfigure(msg *types.Configure) error {
w.idler = newIdler(w.config, w.worker)
w.observer = newObserver(w.config, w.worker)
+ if name, ok := msg.Config.Params["folder-map"]; ok {
+ file, err := homedir.Expand(name)
+ if err != nil {
+ return err
+ }
+ f, err := os.Open(file)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ fmap, order, err := lib.ParseFolderMap(bufio.NewReader(f))
+ if err != nil {
+ return err
+ }
+ w.worker = middleware.NewFolderMapper(w.worker, fmap, order)
+ }
+
return nil
}
diff --git a/worker/imap/idler.go b/worker/imap/idler.go
index 30600764..aa61776d 100644
--- a/worker/imap/idler.go
+++ b/worker/imap/idler.go
@@ -24,14 +24,14 @@ type idler struct {
sync.Mutex
config imapConfig
client *imapClient
- worker *types.Worker
+ worker types.WorkerInteractor
stop chan struct{}
done chan error
waiting bool
idleing bool
}
-func newIdler(cfg imapConfig, w *types.Worker) *idler {
+func newIdler(cfg imapConfig, w types.WorkerInteractor) *idler {
return &idler{config: cfg, worker: w, done: make(chan error)}
}
diff --git a/worker/imap/observer.go b/worker/imap/observer.go
index 1c481bed..7367ff58 100644
--- a/worker/imap/observer.go
+++ b/worker/imap/observer.go
@@ -18,14 +18,14 @@ type observer struct {
sync.Mutex
config imapConfig
client *imapClient
- worker *types.Worker
+ worker types.WorkerInteractor
done chan struct{}
autoReconnect bool
retries int
running bool
}
-func newObserver(cfg imapConfig, w *types.Worker) *observer {
+func newObserver(cfg imapConfig, w types.WorkerInteractor) *observer {
return &observer{config: cfg, worker: w, done: make(chan struct{})}
}
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index d30140a1..f08c0ec9 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -66,7 +66,7 @@ type IMAPWorker struct {
client *imapClient
selected *imap.MailboxStatus
updates chan client.Update
- worker *types.Worker
+ worker types.WorkerInteractor
seqMap SeqMap
delimiter string