Documentation
¶
Overview ¶
Package jmap is the JMAP protocol backend (RFC 8620, 8621; ADR 0037): a backend.Receiver over an account's JMAP session.
Index ¶
- type Config
- type Receiver
- func (r *Receiver) Apply(ctx context.Context, op backend.Op) (backend.Result, error)
- func (r *Receiver) Check(ctx context.Context) (backend.CheckResult, error)
- func (r *Receiver) Close() error
- func (r *Receiver) Describe(ctx context.Context) (backend.Description, error)
- func (r *Receiver) Fetch(ctx context.Context, req backend.ContentRequest) (io.ReadCloser, error)
- func (r *Receiver) Find(ctx context.Context, folder backend.FolderRef, messageID string, size int64) ([]backend.MessageRef, error)
- func (r *Receiver) Headers(ctx context.Context, folder backend.FolderRef, refs []backend.MessageRef, ...) (map[backend.MessageRef][]byte, error)
- func (r *Receiver) Sync(ctx context.Context, req backend.SyncRequest, commit func(backend.Page) error) (bool, error)
- func (r *Receiver) Watch(ctx context.Context, wake func(folders []backend.FolderRef)) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// SessionURL is the session resource, or /.well-known/jmap to discover it.
SessionURL string
Credentials backend.CredentialsFunc
}
Config is how to reach an account.
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
Receiver is a JMAP account's receiving backend. Its folders are mailboxes (FolderRef is the Mailbox id), a message's ServerID and every MessageRef of it are its Email id, and its cursor is the account's Mailbox and Email state.
func (*Receiver) Apply ¶
Apply implements backend.Receiver: each op is one Email/set. The Email id stays the same wherever the message goes, so Done carries it.
func (*Receiver) Describe ¶
Describe implements backend.Receiver. Its first call signs in, fetching the session, so refused credentials are ErrAuthFailed here.
func (*Receiver) Fetch ¶
func (r *Receiver) Fetch(ctx context.Context, req backend.ContentRequest) (io.ReadCloser, error)
Fetch implements backend.Receiver. Sync gives the whole message, which local storage parses, so a part is named by its IMAP part path ("1.2") and cut from the whole message, still transfer-encoded as IMAP gives it. shortcut: a part downloads the whole message; use the part's own blobId from bodyStructure if large mail makes that slow.
func (*Receiver) Find ¶
func (r *Receiver) Find(ctx context.Context, folder backend.FolderRef, messageID string, size int64) ([]backend.MessageRef, error)
Find implements backend.Receiver.
func (*Receiver) Headers ¶
func (r *Receiver) Headers(ctx context.Context, folder backend.FolderRef, refs []backend.MessageRef, fields []string) (map[backend.MessageRef][]byte, error)
Headers implements backend.Receiver. shortcut: one download per message, as Fetch; ask Email/get for the header:* properties of all refs at once if refreshes get slow.
func (*Receiver) Sync ¶
func (r *Receiver) Sync(ctx context.Context, req backend.SyncRequest, commit func(backend.Page) error) (bool, error)
Sync implements backend.Receiver. It reports changes since the cursor and the mail a window wider than the cursor's adds, or everything in the window at first and after the server cannot calculate changes (then each folder is reset first). It always syncs the whole account: Only is not used, nor are Pages and PageSize, so more is false. shortcut: no 加载更早 (Older) on JMAP yet, so it is ErrUnsupported; add an Email/query past each folder's window when core asks for it.
func (*Receiver) Watch ¶
Watch implements backend.Receiver over the session's EventSource. It wakes for every state the server sends, the one on connect included, which covers what changed while it was not connected. When the server closes the stream it connects again. shortcut: no read deadline, so a connection that dies silently is not noticed; ask for pings and time out on their absence if that bites.