aboutsummaryrefslogblamecommitdiffstats
path: root/worker/jmap/cache/mailbox_list.go
blob: fb9bd3ea6ae43b9c2fac0f78fe105389812b94d9 (plain) (tree)































                                                          
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"