mirror of
https://git.sr.ht/~rjarry/aerc
synced 2026-03-02 18:23:33 +01:00
This reverts commits:9e93d9efdb("jmap: fix go static check failure")0465509eed("jmap: skip Email/get call if no emails to get")9f97c698e3("jmap: fetch entire threads") Issues have been reported about disappearing sent messages. Reported-by: Tristan Partin <tristan@partin.io> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tristan Partin <tristan@partin.io>
34 lines
622 B
Go
34 lines
622 B
Go
package cache
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/gob"
|
|
|
|
"git.sr.ht/~rockorager/go-jmap/mail/email"
|
|
"git.sr.ht/~rockorager/go-jmap/mail/mailbox"
|
|
)
|
|
|
|
type jmapObject interface {
|
|
*email.Email |
|
|
*email.QueryResponse |
|
|
*mailbox.Mailbox |
|
|
*FolderContents |
|
|
*IDList
|
|
}
|
|
|
|
func marshal[T jmapObject](obj T) ([]byte, error) {
|
|
buf := bytes.NewBuffer(nil)
|
|
encoder := gob.NewEncoder(buf)
|
|
err := encoder.Encode(obj)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return buf.Bytes(), nil
|
|
}
|
|
|
|
func unmarshal[T jmapObject](data []byte, obj T) error {
|
|
buf := bytes.NewBuffer(data)
|
|
decoder := gob.NewDecoder(buf)
|
|
return decoder.Decode(obj)
|
|
}
|