Files
aerc-fork-mirror/worker/jmap/cache/thread.go
Tim Culverhouse b77bd33d8a jmap: cache threads
Cache threads that we have fetched. Monitor threads for changes, and
fetch any email which we don't have for any thread that changes.

Changelog-added: The JMAP backend now supports full thread fetching
 and caching (limited within a single mailbox).
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-12-21 16:49:31 +01:00

35 lines
639 B
Go

package cache
import (
"git.sr.ht/~rockorager/go-jmap"
)
func (c *JMAPCache) GetThread(id jmap.ID) ([]jmap.ID, error) {
buf, err := c.get(threadKey(id))
if err != nil {
return nil, err
}
var list IDList
err = unmarshal(buf, &list)
if err != nil {
return nil, err
}
return list.IDs, nil
}
func (c *JMAPCache) PutThread(id jmap.ID, list []jmap.ID) error {
buf, err := marshal(&IDList{IDs: list})
if err != nil {
return err
}
return c.put(threadKey(id), buf)
}
func (c *JMAPCache) DeleteThread(id jmap.ID) error {
return c.delete(mailboxKey(id))
}
func threadKey(id jmap.ID) string {
return "thread/" + string(id)
}