diff options
author | Tristan Partin <tristan@partin.io> | 2024-05-20 21:49:24 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-05-28 23:52:39 +0200 |
commit | 9f97c698e3dd8bb98242f0db40946dee514e3ee8 (patch) | |
tree | 8622fe152a60ef9d3879f333cd443fb1b7c6f1e6 /worker/jmap/state.go | |
parent | f9113810cc6cace71ab4dc506f1b106e4ae9f8dd (diff) | |
download | aerc-9f97c698e3dd8bb98242f0db40946dee514e3ee8.tar.gz |
jmap: fetch entire threads
JMAP was missing good thread support, especially when compared to Gmail.
This will fetch entire threads when possible.
Signed-off-by: Tristan Partin <tristan@partin.io>
Diffstat (limited to 'worker/jmap/state.go')
-rw-r--r-- | worker/jmap/state.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/worker/jmap/state.go b/worker/jmap/state.go index 3dbab3fb..833bd151 100644 --- a/worker/jmap/state.go +++ b/worker/jmap/state.go @@ -3,6 +3,7 @@ package jmap import ( "git.sr.ht/~rockorager/go-jmap" "git.sr.ht/~rockorager/go-jmap/mail/mailbox" + "git.sr.ht/~rockorager/go-jmap/mail/thread" ) func (w *JMAPWorker) getMailboxState() (string, error) { @@ -27,3 +28,28 @@ func (w *JMAPWorker) getMailboxState() (string, error) { // This should be an impossibility return "", nil } + +func (w *JMAPWorker) getThreadState() (string, error) { + var req jmap.Request + + // TODO: This is a junk JMAP ID because Go's JSON serialization doesn't + // send empty slices as arrays, WTF. + req.Invoke(&thread.Get{Account: w.accountId, IDs: []jmap.ID{jmap.ID("00")}}) + resp, err := w.Do(&req) + if err != nil { + return "", err + } + + for _, inv := range resp.Responses { + switch r := inv.Args.(type) { + case *thread.GetResponse: + return r.State, nil + case *jmap.MethodError: + return "", wrapMethodError(r) + + } + } + + // This should be an impossibility + return "", nil +} |