aboutsummaryrefslogtreecommitdiffstats
path: root/worker/jmap
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-06-24 14:42:00 +0200
committerRobin Jarry <robin@jarry.cc>2023-06-25 22:28:40 +0200
commitfb99486ad073bb99ca526add707d774464159e8a (patch)
tree32a2ee9f0ac57d827dbe441cc662bb00bb8fa367 /worker/jmap
parentf7837edbb203a489fbfdd95f6b427906a58fbbdb (diff)
downloadaerc-fb99486ad073bb99ca526add707d774464159e8a.tar.gz
jmap: avoid displaying archive folder when use-labels=true
When archiving a message, the counts of archive folder are changed. When use-labels=true, the archive folder is hidden and should remain so. Do not send updates to the UI. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'worker/jmap')
-rw-r--r--worker/jmap/directories.go9
-rw-r--r--worker/jmap/push.go3
-rw-r--r--worker/jmap/worker.go16
3 files changed, 22 insertions, 6 deletions
diff --git a/worker/jmap/directories.go b/worker/jmap/directories.go
index b3297169..0fa3d898 100644
--- a/worker/jmap/directories.go
+++ b/worker/jmap/directories.go
@@ -244,8 +244,15 @@ func (w *JMAPWorker) handleCreateDirectory(msg *types.CreateDirectory) error {
var req jmap.Request
var parentId, id jmap.ID
- if _, ok := w.dir2mbox[msg.Directory]; ok {
+ if id, ok := w.dir2mbox[msg.Directory]; ok {
// directory already exists
+ mbox, err := w.cache.GetMailbox(id)
+ if err != nil {
+ return err
+ }
+ if mbox.Role == mailbox.RoleArchive && w.config.useLabels {
+ return errNoop
+ }
return nil
}
if parent := path.Dir(msg.Directory); parent != "" && parent != "." {
diff --git a/worker/jmap/push.go b/worker/jmap/push.go
index 2582b17a..320fee4f 100644
--- a/worker/jmap/push.go
+++ b/worker/jmap/push.go
@@ -283,6 +283,9 @@ func (w *JMAPWorker) refresh(newState jmap.TypeState) error {
for _, id := range changedMboxIds {
mbox := mboxes[id]
+ if mbox.Role == mailbox.RoleArchive && w.config.useLabels {
+ continue
+ }
newDir := w.MailboxPath(mbox)
dir, ok := w.mbox2dir[id]
if ok {
diff --git a/worker/jmap/worker.go b/worker/jmap/worker.go
index efd6b041..0b1c57ae 100644
--- a/worker/jmap/worker.go
+++ b/worker/jmap/worker.go
@@ -20,7 +20,10 @@ func init() {
handlers.RegisterWorkerFactory("jmap", NewJMAPWorker)
}
-var errUnsupported = errors.New("unsupported")
+var (
+ errNoop error = errors.New("noop")
+ errUnsupported error = errors.New("unsupported")
+)
type JMAPWorker struct {
config struct {
@@ -102,9 +105,6 @@ func (w *JMAPWorker) PathSeparator() string {
func (w *JMAPWorker) handleMessage(msg types.WorkerMessage) error {
switch msg := msg.(type) {
- case *types.Unsupported:
- // No-op
- break
case *types.Configure:
return w.handleConfigure(msg)
case *types.Connect:
@@ -176,6 +176,10 @@ func (w *JMAPWorker) Run() {
msg = w.w.ProcessAction(msg)
err := w.handleMessage(msg)
switch {
+ case errors.Is(err, errNoop):
+ // Operation did not have any effect.
+ // Do *NOT* send a Done message.
+ break
case errors.Is(err, errUnsupported):
w.w.PostMessage(&types.Unsupported{
Message: types.RespondTo(msg),
@@ -185,7 +189,9 @@ func (w *JMAPWorker) Run() {
Message: types.RespondTo(msg),
Error: err,
}, nil)
- default:
+ default: // err == nil
+ // Operation is finished.
+ // Send a Done message.
w.w.PostMessage(&types.Done{
Message: types.RespondTo(msg),
}, nil)