diff options
author | Tristan Partin <tristan@partin.io> | 2024-05-11 14:15:04 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-05-28 23:52:37 +0200 |
commit | f9113810cc6cace71ab4dc506f1b106e4ae9f8dd (patch) | |
tree | 79c3a7b307eb1a9fe0cf006826cc00afabd86b6c /worker/jmap/state.go | |
parent | 36457f82f22dd98125f845c908a342a1bebb3a8f (diff) | |
download | aerc-f9113810cc6cace71ab4dc506f1b106e4ae9f8dd.tar.gz |
jmap: invalidate cache if mailbox state is not consistent
We weren't checking if the cached state was the same as the remote state
before reading it. This led to aerc not knowing about new mailboxes on
the remote.
Signed-off-by: Tristan Partin <tristan@partin.io>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/jmap/state.go')
-rw-r--r-- | worker/jmap/state.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/worker/jmap/state.go b/worker/jmap/state.go new file mode 100644 index 00000000..3dbab3fb --- /dev/null +++ b/worker/jmap/state.go @@ -0,0 +1,29 @@ +package jmap + +import ( + "git.sr.ht/~rockorager/go-jmap" + "git.sr.ht/~rockorager/go-jmap/mail/mailbox" +) + +func (w *JMAPWorker) getMailboxState() (string, error) { + var req jmap.Request + + req.Invoke(&mailbox.Get{Account: w.accountId, IDs: make([]jmap.ID, 0)}) + resp, err := w.Do(&req) + if err != nil { + return "", err + } + + for _, inv := range resp.Responses { + switch r := inv.Args.(type) { + case *mailbox.GetResponse: + return r.State, nil + case *jmap.MethodError: + return "", wrapMethodError(r) + + } + } + + // This should be an impossibility + return "", nil +} |