aboutsummaryrefslogtreecommitdiffstats
path: root/worker/jmap/cache/mailbox_list.go
blob: fb9bd3ea6ae43b9c2fac0f78fe105389812b94d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package cache

import (
	"git.sr.ht/~rockorager/go-jmap"
)

type IDList struct {
	IDs []jmap.ID
}

func (c *JMAPCache) GetMailboxList() ([]jmap.ID, error) {
	buf, err := c.get(mailboxListKey)
	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) PutMailboxList(list []jmap.ID) error {
	buf, err := marshal(&IDList{IDs: list})
	if err != nil {
		return err
	}
	return c.put(mailboxListKey, buf)
}

const mailboxListKey = "mailbox/list"