aboutsummaryrefslogtreecommitdiffstats
path: root/worker/maildir/worker.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2023-04-16 09:53:38 -0500
committerRobin Jarry <robin@jarry.cc>2023-04-22 22:40:12 +0200
commit87765f93de9b5c123be5beee45b62425c71c2005 (patch)
tree0c9401dc48b48d4592900109d592befc5c624f21 /worker/maildir/worker.go
parent82de08a8a3f55c438d8808e3c759e3d99261c4b8 (diff)
downloadaerc-87765f93de9b5c123be5beee45b62425c71c2005.tar.gz
capabilities: report capabilities from backend
Use the Backend interface to report Backend capabilities. Previously, these were reported via a DirectoryInfo message, however they have nothing to do with a directory and should be reported directly by the backend. Add Capabilities method to Backend interface, satisfy this in each backend, and use it on the UI side. Remove Caps field from DirectoryInfo Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry<robin@jarry.cc>
Diffstat (limited to 'worker/maildir/worker.go')
-rw-r--r--worker/maildir/worker.go29
1 files changed, 22 insertions, 7 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go
index dc794a10..d8b3e816 100644
--- a/worker/maildir/worker.go
+++ b/worker/maildir/worker.go
@@ -43,6 +43,7 @@ type Worker struct {
watcher types.FSWatcher
currentSortCriteria []*types.SortCriterion
maildirpp bool // whether to use Maildir++ directory layout
+ capabilities *models.Capabilities
}
// NewWorker creates a new maildir worker with the provided worker.
@@ -51,7 +52,14 @@ func NewWorker(worker *types.Worker) (types.Backend, error) {
if err != nil {
return nil, fmt.Errorf("could not create file system watcher: %w", err)
}
- return &Worker{worker: worker, watcher: watch}, nil
+ return &Worker{
+ capabilities: &models.Capabilities{
+ Sort: true,
+ Thread: true,
+ },
+ worker: worker,
+ watcher: watch,
+ }, nil
}
// NewMaildirppWorker creates a new Maildir++ worker with the provided worker.
@@ -60,7 +68,15 @@ func NewMaildirppWorker(worker *types.Worker) (types.Backend, error) {
if err != nil {
return nil, fmt.Errorf("could not create file system watcher: %w", err)
}
- return &Worker{worker: worker, watcher: watch, maildirpp: true}, nil
+ return &Worker{
+ capabilities: &models.Capabilities{
+ Sort: true,
+ Thread: true,
+ },
+ worker: worker,
+ watcher: watch,
+ maildirpp: true,
+ }, nil
}
// Run starts the worker's message handling loop.
@@ -75,6 +91,10 @@ func (w *Worker) Run() {
}
}
+func (w *Worker) Capabilities() *models.Capabilities {
+ return w.capabilities
+}
+
func (w *Worker) handleAction(action types.WorkerMessage) {
msg := w.worker.ProcessAction(action)
switch msg := msg.(type) {
@@ -177,11 +197,6 @@ func (w *Worker) getDirectoryInfo(name string) *models.DirectoryInfo {
Unseen: 0,
AccurateCounts: false,
-
- Caps: &models.Capabilities{
- Sort: true,
- Thread: true,
- },
}
dir := w.c.Store.Dir(name)