aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)