mirror of
https://git.sr.ht/~rjarry/aerc
synced 2026-03-02 18:23:33 +01:00
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>
35 lines
639 B
Go
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)
|
|
}
|