api

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api is the maild RPC contract: JSON-RPC 2.0 over a Unix socket, specified in docs/specs/rpc-protocol.md. zz_generated.go is generated by tools/rpcgen from schema/rpc; this file and its siblings name the runtime it relies on, which lodge's kit provides (github.com/frostyard/lodge/kit/jsonrpc). Edit the schema, never the generated file.

Index

Constants

View Source
const (
	MaxMessageSize = jsonrpc.MaxMessageSize
	EventBuffer    = jsonrpc.EventBuffer
	EventMethod    = jsonrpc.EventMethod
)

The wire limits and types (jsonrpc).

View Source
const Protocol = 1

Protocol is the protocol major version this package speaks.

Variables

View Source
var (
	ErrParseError       = &Error{Code: CodeParseError}
	ErrInvalidRequest   = &Error{Code: CodeInvalidRequest}
	ErrMethodNotFound   = &Error{Code: CodeMethodNotFound}
	ErrInvalidParams    = &Error{Code: CodeInvalidParams}
	ErrInternal         = &Error{Code: CodeInternal}
	ErrNotFound         = &Error{Code: CodeNotFound}
	ErrConflict         = &Error{Code: CodeConflict}
	ErrProtocolMismatch = &Error{Code: CodeProtocolMismatch}
	ErrNotReady         = &Error{Code: CodeNotReady}
	ErrUnavailable      = &Error{Code: CodeUnavailable}
	ErrAuthRequired     = &Error{Code: CodeAuthRequired}
	ErrNotifyRequired   = &Error{Code: CodeNotifyRequired}
)

Sentinels for errors.Is: an *Error matches the sentinel with its code.

View Source
var ErrEventsOverflow = jsonrpc.ErrEventsOverflow

ErrEventsOverflow means the caller stopped reading Client.Notifications.

View Source
var ErrScope = errors.New("scope")

ErrScope means a scope does not parse.

View Source
var Methods = []string{}/* 120 elements not displayed */

Methods is every method's wire name, in schema order.

Functions

func Admits

func Admits(method string, kind CallerKind) bool

Admits reports whether method admits callers of kind, by the schema's callers. An unknown method admits none.

func Dial

func Dial(ctx context.Context, socketPath, clientName string) (*Client, *Hello, error)

Dial connects to the maild socket (a named pipe on Windows) and completes rpc.hello.

func HasMethod

func HasMethod(method string) bool

HasMethod reports whether the schema defines method.

func WithCaller

func WithCaller(ctx context.Context, c Caller) context.Context

WithCaller returns ctx carrying c; the RPC server sets it for every request on a connection that is not local.

func WithConn

func WithConn(ctx context.Context, c Conn) context.Context

WithConn returns ctx carrying c; the RPC server sets it for every request.

Types

type Account

type Account struct {
	// Stable local identifier.
	ID   int64       `json:"id"`
	Kind AccountKind `json:"kind"`
	// The account's primary address.
	Email string `json:"email"`
	// The sender name used in From headers.
	DisplayName string       `json:"displayName"`
	Auth        AuthKind     `json:"auth"`
	IMAP        ServerConfig `json:"imap"`
	SMTP        ServerConfig `json:"smtp"`
	CreatedAt   time.Time    `json:"createdAt"`
	// maild makes no changes on the server: no flags, moves, deletes, sends or
	// draft copies.
	ReadOnly bool `json:"readOnly"`
	// New mail in the inbox shows a desktop notification.
	Notify bool `json:"notify"`
	// maild keeps the messages that arrived in the last syncDays days; 0 keeps
	// every message (ADR-0016).
	SyncDays int64 `json:"syncDays"`
	// A password or OAuth token is stored and the server has not refused it.
	SignedIn bool `json:"signedIn"`
}

Account: A configured mail account.

type AccountAuthorizeParams

type AccountAuthorizeParams struct {
	ID int64 `json:"id"`
}

AccountAuthorizeParams holds the params of account.authorize.

type AccountChanged

type AccountChanged struct {
	ID      int64 `json:"id"`
	Deleted bool  `json:"deleted"`
}

AccountChanged: An account was created, updated or deleted, or its services or collections changed.

func (AccountChanged) Durable

func (AccountChanged) Durable() bool

Durable reports whether AccountChanged is kept in the changes log.

func (AccountChanged) EventName

func (AccountChanged) EventName() string

EventName is the wire name of AccountChanged.

type AccountClient

type AccountClient struct {
	// contains filtered or unexported fields
}

AccountClient calls the account methods; it implements AccountService.

func (AccountClient) Authorize

Authorize calls account.authorize.

func (AccountClient) Collections

Collections calls account.collections.

func (AccountClient) Create

Create calls account.create.

func (AccountClient) Delete

Delete calls account.delete.

func (AccountClient) Discover

Discover calls account.discover.

func (AccountClient) FinishSignIn

FinishSignIn calls account.finishSignIn.

func (AccountClient) Get

Get calls account.get.

func (AccountClient) List

List calls account.list.

func (AccountClient) Services

Services calls account.services.

func (AccountClient) SetCollection

SetCollection calls account.setCollection.

func (AccountClient) SetPassword

SetPassword calls account.setPassword.

func (AccountClient) SetService

SetService calls account.setService.

func (AccountClient) Update

Update calls account.update.

func (AccountClient) Verify

Verify calls account.verify.

type AccountCollectionsParams

type AccountCollectionsParams struct {
	AccountID *int64          `json:"accountId,omitzero"`
	Kind      *CollectionKind `json:"kind,omitzero"`
}

AccountCollectionsParams holds the params of account.collections.

type AccountCreateParams

type AccountCreateParams struct {
	Kind        AccountKind   `json:"kind"`
	Email       string        `json:"email"`
	DisplayName string        `json:"displayName"`
	Auth        AuthKind      `json:"auth"`
	IMAP        *ServerConfig `json:"imap,omitzero"`
	SMTP        *ServerConfig `json:"smtp,omitzero"`
	// Default false.
	ReadOnly *bool `json:"readOnly,omitzero"`
	// Default true.
	Notify *bool `json:"notify,omitzero"`
	// Default 0: every message. At most 36500.
	SyncDays *int64 `json:"syncDays,omitzero"`
}

AccountCreateParams holds the params of account.create.

type AccountDeleteParams

type AccountDeleteParams struct {
	ID int64 `json:"id"`
}

AccountDeleteParams holds the params of account.delete.

type AccountDiscoverParams

type AccountDiscoverParams struct {
	Email string `json:"email"`
}

AccountDiscoverParams holds the params of account.discover.

type AccountFinishSignInParams

type AccountFinishSignInParams struct {
	// The address the provider sent the browser to, with its query.
	URL string `json:"url"`
}

AccountFinishSignInParams holds the params of account.finishSignIn.

type AccountGetParams

type AccountGetParams struct {
	ID int64 `json:"id"`
}

AccountGetParams holds the params of account.get.

type AccountKind

type AccountKind string

AccountKind: The provider family, which selects the sync strategy and server quirks.

const (
	// Generic IMAP and SMTP.
	AccountKindIMAP AccountKind = "imap"
	// Google Gmail and Workspace (labels, X-GM extensions).
	AccountKindGmail AccountKind = "gmail"
	// Microsoft 365 and Outlook.com.
	AccountKindMicrosoft AccountKind = "microsoft"
	// Apple iCloud Mail.
	AccountKindICloud AccountKind = "icloud"
)

func (AccountKind) Valid

func (v AccountKind) Valid() bool

Valid reports whether v is one of the declared values.

type AccountListParams

type AccountListParams struct{}

AccountListParams holds the params of account.list.

type AccountService

type AccountService interface {
	// List implements account.list. All accounts, oldest first.
	List(ctx context.Context, p *AccountListParams) ([]Account, error)
	// Get implements account.get. One account.
	Get(ctx context.Context, p *AccountGetParams) (*Account, error)
	// Create implements account.create. Add an account. The email address must be
	// unique. Gmail and iCloud accounts may leave the servers out; their profiles
	// fill them in.
	Create(ctx context.Context, p *AccountCreateParams) (*Account, error)
	// Update implements account.update. Change an account's settings. Omitted
	// fields keep their values.
	Update(ctx context.Context, p *AccountUpdateParams) (*Account, error)
	// Delete implements account.delete. Remove an account and everything stored
	// for it.
	Delete(ctx context.Context, p *AccountDeleteParams) error
	// SetPassword implements account.setPassword. Store the password (or
	// app-specific password) the account logs in with, and reconnect.
	SetPassword(ctx context.Context, p *AccountSetPasswordParams) error
	// Discover implements account.discover. Find server settings for an address
	// (provider profiles, autoconfig, the ISPDB, SRV records).
	Discover(ctx context.Context, p *AccountDiscoverParams) (*Discovery, error)
	// Authorize implements account.authorize. Start an OAuth sign-in for an
	// oauth2 account. maild listens on a loopback port for the browser's return
	// for 5 minutes, then stores the token, reconnects, and emits
	// account.changed. The sign-in also finishes when a client sends the address
	// the browser could not open to account.finishSignIn (ADR-0043).
	Authorize(ctx context.Context, p *AccountAuthorizeParams) (*AuthorizeResult, error)
	// FinishSignIn implements account.finishSignIn. Finish a waiting OAuth
	// sign-in with the address that the browser could not open (ADR-0043). maild
	// stores the token, reconnects and emits account.changed.
	FinishSignIn(ctx context.Context, p *AccountFinishSignInParams) (*Account, error)
	// Verify implements account.verify. Compare the stored mail with the server,
	// changing nothing on either side.
	Verify(ctx context.Context, p *AccountVerifyParams) (*VerifyReport, error)
	// Services implements account.services. An account's contacts, calendar and
	// tasks services, in that order.
	Services(ctx context.Context, p *AccountServicesParams) ([]ServiceSettings, error)
	// SetService implements account.setService. Turn a service on or off. Turning
	// one on without a url takes the provider's profile or discovers the server
	// (well-known URLs, then SRV records) and syncs it; a Google account whose
	// grant lacks the service's scope waits for account.authorize. Turning one
	// off stops syncing and keeps what is stored.
	SetService(ctx context.Context, p *AccountSetServiceParams) (*ServiceSettings, error)
	// Collections implements account.collections. Address books, calendars and
	// task lists, by account, then by the server's order.
	Collections(ctx context.Context, p *AccountCollectionsParams) ([]Collection, error)
	// SetCollection implements account.setCollection. Show or hide a collection,
	// or make it the default of its kind for its account. account.changed
	// follows; showing or hiding also sends the collection's domain event
	// (people.changed, calendar.changed or tasks.changed).
	SetCollection(ctx context.Context, p *AccountSetCollectionParams) (*Collection, error)
}

AccountService: Mail accounts and their server settings. Credentials are write-only over RPC; account.setPassword stores one and no method returns it.

type AccountServicesParams

type AccountServicesParams struct {
	ID int64 `json:"id"`
}

AccountServicesParams holds the params of account.services.

type AccountSetCollectionParams

type AccountSetCollectionParams struct {
	ID      int64 `json:"id"`
	Enabled *bool `json:"enabled,omitzero"`
	// Only true: the previous default stops being one.
	IsDefault *bool `json:"isDefault,omitzero"`
}

AccountSetCollectionParams holds the params of account.setCollection.

type AccountSetPasswordParams

type AccountSetPasswordParams struct {
	ID       int64  `json:"id"`
	Password string `json:"password"`
}

AccountSetPasswordParams holds the params of account.setPassword.

type AccountSetServiceParams

type AccountSetServiceParams struct {
	ID      int64       `json:"id"`
	Service ServiceKind `json:"service"`
	Enabled bool        `json:"enabled"`
	// The server's address, when discovery finds nothing.
	URL *string `json:"url,omitzero"`
}

AccountSetServiceParams holds the params of account.setService.

type AccountUpdateParams

type AccountUpdateParams struct {
	ID          int64         `json:"id"`
	DisplayName *string       `json:"displayName,omitzero"`
	IMAP        *ServerConfig `json:"imap,omitzero"`
	SMTP        *ServerConfig `json:"smtp,omitzero"`
	ReadOnly    *bool         `json:"readOnly,omitzero"`
	Notify      *bool         `json:"notify,omitzero"`
	// A new window: the next pass fetches what it adds and drops what it leaves.
	SyncDays *int64 `json:"syncDays,omitzero"`
}

AccountUpdateParams holds the params of account.update.

type AccountVerifyParams

type AccountVerifyParams struct {
	ID int64 `json:"id"`
}

AccountVerifyParams holds the params of account.verify.

type Address

type Address struct {
	// Display name; may be empty.
	Name    string `json:"name"`
	Address string `json:"address"`
}

Address: One mailbox address.

type AddressClient

type AddressClient struct {
	// contains filtered or unexported fields
}

AddressClient calls the address methods; it implements AddressService.

func (AddressClient) Suggest

Suggest calls address.suggest.

type AddressService

type AddressService interface {
	// Suggest implements address.suggest. Addresses whose address, or any word of
	// whose name, starts with prefix (case-insensitively), most used first.
	Suggest(ctx context.Context, p *AddressSuggestParams) ([]Address, error)
}

AddressService: Addresses seen in stored and sent mail, for completing recipients.

type AddressSuggestParams

type AddressSuggestParams struct {
	Prefix string `json:"prefix"`
	// At most this many; default 10.
	Limit *int64 `json:"limit,omitzero"`
}

AddressSuggestParams holds the params of address.suggest.

type Announcement

type Announcement struct {
	// The sender, or "N new messages" for a group.
	Title string `json:"title"`
	// The subject (after "Reminder: " for a Remind Me reminder) and a line of
	// preview, or the senders of a group.
	Body string `json:"body"`
	// The message it opens; absent for a group.
	MessageID *int64 `json:"messageId,omitzero"`
}

Announcement: One notification of new mail, as maild's desktop notifications word it (docs/design/desktop.md, Notifications).

type Attendee

type Attendee struct {
	// Lowercased.
	Email  string       `json:"email"`
	Name   string       `json:"name"`
	Role   AttendeeRole `json:"role"`
	Answer PartStat     `json:"answer"`
	// One of the account's own addresses.
	IsUser bool `json:"isUser"`
}

Attendee: An organizer or attendee.

type AttendeeRole

type AttendeeRole string

AttendeeRole: An attendee's ROLE.

const (
	AttendeeRoleChair    AttendeeRole = "chair"
	AttendeeRoleRequired AttendeeRole = "required"
	AttendeeRoleOptional AttendeeRole = "optional"
	// Copied for information.
	AttendeeRoleNone AttendeeRole = "none"
)

func (AttendeeRole) Valid

func (v AttendeeRole) Valid() bool

Valid reports whether v is one of the declared values.

type AuthKind

type AuthKind string

AuthKind: How the account authenticates to its servers.

const (
	// A password or app-specific password, kept in the secret store.
	AuthKindPassword AuthKind = "password"
	// OAuth 2.0 tokens (SASL XOAUTH2), kept in the secret store.
	AuthKindOAuth2 AuthKind = "oauth2"
)

func (AuthKind) Valid

func (v AuthKind) Valid() bool

Valid reports whether v is one of the declared values.

type AuthorizeResult

type AuthorizeResult struct {
	// Open in the system browser; maild finishes the sign-in when the browser
	// returns to its loopback, or when a client sends the address to
	// account.finishSignIn.
	URL string `json:"url"`
}

AuthorizeResult: An OAuth sign-in in progress.

type Awaiting

type Awaiting struct {
	// How many match, before limit.
	Total   int64            `json:"total"`
	Threads []AwaitingThread `json:"threads"`
}

Awaiting: Conversations waiting on a reply, those with a VIP first, then the newest first.

type AwaitingThread

type AwaitingThread struct {
	ThreadID  int64 `json:"threadId"`
	AccountID int64 `json:"accountId"`
	// The thread's newest message.
	Message MessageSummary `json:"message"`
	// The first 10 of the newest message's To and Cc.
	Recipients []Address `json:"recipients"`
	// How many addresses its To and Cc hold.
	RecipientCount int64 `json:"recipientCount"`
	// awaitingReply: the sender is a VIP. awaitingOthers: a recipient is.
	Vip bool `json:"vip"`
	// Whole days of 24 hours since the newest message.
	WaitingDays int64 `json:"waitingDays"`
}

AwaitingThread: A conversation waiting on a reply (ADR-0042).

type BlockAction

type BlockAction string

BlockAction: What happens to new mail from a blocked sender (ADR-0028).

const (
	// It stays where it arrives, marked as blocked (the default).
	BlockActionMark BlockAction = "mark"
	// New inbox mail moves to the Trash as it arrives.
	BlockActionTrash BlockAction = "trash"
)

func (BlockAction) Valid

func (v BlockAction) Valid() bool

Valid reports whether v is one of the declared values.

type BlockAddParams

type BlockAddParams struct {
	// At least one.
	Addresses []string `json:"addresses"`
}

BlockAddParams holds the params of block.add.

type BlockChanged

type BlockChanged struct{}

BlockChanged: Senders were blocked or unblocked.

func (BlockChanged) Durable

func (BlockChanged) Durable() bool

Durable reports whether BlockChanged is kept in the changes log.

func (BlockChanged) EventName

func (BlockChanged) EventName() string

EventName is the wire name of BlockChanged.

type BlockClient

type BlockClient struct {
	// contains filtered or unexported fields
}

BlockClient calls the block methods; it implements BlockService.

func (BlockClient) Add

Add calls block.add.

func (BlockClient) List

List calls block.list.

func (BlockClient) Remove

Remove calls block.remove.

type BlockListParams

type BlockListParams struct{}

BlockListParams holds the params of block.list.

type BlockRemoveParams

type BlockRemoveParams struct {
	// At least one.
	Addresses []string `json:"addresses"`
}

BlockRemoveParams holds the params of block.remove.

type BlockService

type BlockService interface {
	// List implements block.list. Every blocked sender, by address.
	List(ctx context.Context, p *BlockListParams) ([]BlockedSender, error)
	// Add implements block.add. Block addresses. Addresses already blocked stay
	// as they are.
	Add(ctx context.Context, p *BlockAddParams) ([]BlockedSender, error)
	// Remove implements block.remove. Unblock addresses.
	Remove(ctx context.Context, p *BlockRemoveParams) error
}

BlockService: Blocked senders (ADR-0028): their mail never notifies, and is marked as blocked or moved to the Trash as it arrives (the blockAction setting).

type BlockedSender

type BlockedSender struct {
	// Lowercased.
	Address string `json:"address"`
	// The name last seen with the address in mail, else empty.
	Name string `json:"name"`
	// When it was blocked.
	At time.Time `json:"at"`
}

BlockedSender: One blocked address.

type Body

type Body struct {
	// The text/plain part, or text derived from the HTML part.
	Text string `json:"text"`
	// Whether an HTML part exists (rendered from M2 on).
	HasHTML bool `json:"hasHtml"`
}

Body: A message's readable text.

type CalendarChanged

type CalendarChanged struct {
	AccountID int64 `json:"accountId"`
}

CalendarChanged: An account's calendars or events changed; views refetch their ranges.

func (CalendarChanged) Durable

func (CalendarChanged) Durable() bool

Durable reports whether CalendarChanged is kept in the changes log.

func (CalendarChanged) EventName

func (CalendarChanged) EventName() string

EventName is the wire name of CalendarChanged.

type CalendarClient

type CalendarClient struct {
	// contains filtered or unexported fields
}

CalendarClient calls the calendar methods; it implements CalendarService.

func (CalendarClient) Create

Create calls calendar.create.

func (CalendarClient) Delete

Delete calls calendar.delete.

func (CalendarClient) Dismiss

Dismiss calls calendar.dismiss.

func (CalendarClient) Event

Event calls calendar.event.

func (CalendarClient) Invitation

Invitation calls calendar.invitation.

func (CalendarClient) Range

Range calls calendar.range.

func (CalendarClient) Reminders

Reminders calls calendar.reminders.

func (CalendarClient) Respond

Respond calls calendar.respond.

func (CalendarClient) Restore

Restore calls calendar.restore.

func (CalendarClient) Snooze

Snooze calls calendar.snooze.

func (CalendarClient) Update

Update calls calendar.update.

type CalendarCreateParams

type CalendarCreateParams struct {
	// Default: the default calendar of the first account with the calendar
	// service on.
	CalendarID *int64 `json:"calendarId,omitzero"`
	// With start, end and timeZone, or startDate and endDate.
	Fields EventFields `json:"fields"`
	// true sends what the change tells invitees; required when it tells any
	// (notifyRequired). false is invalidParams where the server cannot be kept
	// quiet (ADR-0035).
	Notify *bool `json:"notify,omitzero"`
}

CalendarCreateParams holds the params of calendar.create.

type CalendarDeleteParams

type CalendarDeleteParams struct {
	ID           int64   `json:"id"`
	RecurrenceID *string `json:"recurrenceId,omitzero"`
	// Required with recurrenceId.
	Scope *EventScope `json:"scope,omitzero"`
	// true sends what the change tells invitees; required when it tells any
	// (notifyRequired). false is invalidParams where the server cannot be kept
	// quiet (ADR-0035).
	Notify *bool `json:"notify,omitzero"`
}

CalendarDeleteParams holds the params of calendar.delete.

type CalendarDismissParams

type CalendarDismissParams struct {
	IDs []string `json:"ids"`
}

CalendarDismissParams holds the params of calendar.dismiss.

type CalendarEvent

type CalendarEvent struct {
	ID           int64  `json:"id"`
	RecurrenceID string `json:"recurrenceId"`
	CalendarID   int64  `json:"calendarId"`
	AccountID    int64  `json:"accountId"`
	UID          string `json:"uid"`
	Summary      string `json:"summary"`
	Location     string `json:"location"`
	// Plain text.
	Description string    `json:"description"`
	AllDay      bool      `json:"allDay"`
	Start       time.Time `json:"start"`
	End         time.Time `json:"end"`
	StartDate   string    `json:"startDate"`
	EndDate     string    `json:"endDate"`
	// The IANA zone the event was made in, or empty (UTC, floating or all-day).
	TimeZone  string `json:"timeZone"`
	Recurring bool   `json:"recurring"`
	// For an occurrence of a series: whether it is the series' first, from which
	// All Future Events is All Events (ADR-0031).
	First *bool `json:"first,omitzero"`
	// The RRULE, RDATE and EXDATE lines as sent, for the app to describe; empty
	// for a single event.
	Recurrence  string      `json:"recurrence"`
	Status      EventStatus `json:"status"`
	Transparent bool        `json:"transparent"`
	Organizer   *Attendee   `json:"organizer,omitzero"`
	// Without the organizer.
	Attendees []Attendee `json:"attendees"`
	// The user's answer, when invited.
	Answer *PartStat `json:"answer,omitzero"`
	// Reminders shown, as minutes before the start (negative: after).
	Alarms   []int64 `json:"alarms"`
	ReadOnly bool    `json:"readOnly"`
}

CalendarEvent: An event in full; for an occurrence of a series, that occurrence's times.

type CalendarEventParams

type CalendarEventParams struct {
	ID           int64   `json:"id"`
	RecurrenceID *string `json:"recurrenceId,omitzero"`
}

CalendarEventParams holds the params of calendar.event.

type CalendarInvitationParams

type CalendarInvitationParams struct {
	MessageID int64 `json:"messageId"`
}

CalendarInvitationParams holds the params of calendar.invitation.

type CalendarRangeParams

type CalendarRangeParams struct {
	// The first day, YYYY-MM-DD.
	From string `json:"from"`
	// The day after the last; at most 400 days after from.
	To string `json:"to"`
	// The IANA zone the days are in. Default: maild's local zone.
	TimeZone *string `json:"timeZone,omitzero"`
	// Only these calendars.
	CalendarIDs []int64 `json:"calendarIds,omitzero"`
}

CalendarRangeParams holds the params of calendar.range.

type CalendarRefused

type CalendarRefused struct {
	AccountID int64 `json:"accountId"`
	// Absent when the event is gone.
	EventID *int64 `json:"eventId,omitzero"`
	Summary string `json:"summary"`
	// changed (another client changed the same fields), deleted, or refused.
	Reason string `json:"reason"`
}

CalendarRefused: The server refused a change and it could not be applied again; the server's version stands (ADR-0030).

func (CalendarRefused) Durable

func (CalendarRefused) Durable() bool

Durable reports whether CalendarRefused is kept in the changes log.

func (CalendarRefused) EventName

func (CalendarRefused) EventName() string

EventName is the wire name of CalendarRefused.

type CalendarReminders

type CalendarReminders struct {
	// How many are due now.
	Count int64 `json:"count"`
}

CalendarReminders: Reminders became due; the app raises its reminder window with calendar.reminders.

func (CalendarReminders) Durable

func (CalendarReminders) Durable() bool

Durable reports whether CalendarReminders is kept in the changes log.

func (CalendarReminders) EventName

func (CalendarReminders) EventName() string

EventName is the wire name of CalendarReminders.

type CalendarRemindersParams

type CalendarRemindersParams struct{}

CalendarRemindersParams holds the params of calendar.reminders.

type CalendarRespondParams

type CalendarRespondParams struct {
	MessageID *int64 `json:"messageId,omitzero"`
	EventID   *int64 `json:"eventId,omitzero"`
	// Answer one occurrence only.
	RecurrenceID *string `json:"recurrenceId,omitzero"`
	// accepted, declined or tentative.
	Answer PartStat `json:"answer"`
	// A note for the organizer.
	Comment *string `json:"comment,omitzero"`
}

CalendarRespondParams holds the params of calendar.respond.

type CalendarRestoreParams

type CalendarRestoreParams struct {
	RestoreID string `json:"restoreId"`
	// true sends what the change tells invitees; required when it tells any
	// (notifyRequired). false is invalidParams where the server cannot be kept
	// quiet (ADR-0035).
	Notify *bool `json:"notify,omitzero"`
}

CalendarRestoreParams holds the params of calendar.restore.

type CalendarService

type CalendarService interface {
	// Range implements calendar.range. The occurrences that overlap the days from
	// to to, in start order, from enabled calendars of accounts with the calendar
	// service on.
	Range(ctx context.Context, p *CalendarRangeParams) ([]Occurrence, error)
	// Event implements calendar.event. An event, or one occurrence of a series.
	Event(ctx context.Context, p *CalendarEventParams) (*CalendarEvent, error)
	// Invitation implements calendar.invitation. The invitation in a message's
	// text/calendar part.
	Invitation(ctx context.Context, p *CalendarInvitationParams) (*Invitation, error)
	// Respond implements calendar.respond. Answer an invitation, from its message
	// or its stored event. maild changes the user's PARTSTAT in the stored event
	// and lets the server tell the organizer, or sends the organizer an iTIP
	// REPLY itself when the server does not (ADR-0019). An accepted invitation
	// not yet stored goes into the account's default calendar.
	Respond(ctx context.Context, p *CalendarRespondParams) (*CalendarEvent, error)
	// Reminders implements calendar.reminders. The reminders that are due now and
	// neither dismissed nor snoozed, oldest first.
	Reminders(ctx context.Context, p *CalendarRemindersParams) ([]Reminder, error)
	// Snooze implements calendar.snooze. Show reminders again at until.
	Snooze(ctx context.Context, p *CalendarSnoozeParams) error
	// Dismiss implements calendar.dismiss. Stop showing reminders.
	Dismiss(ctx context.Context, p *CalendarDismissParams) error
	// Create implements calendar.create. Add an event and write it to the server
	// (ADR-0030). The views show it at once.
	Create(ctx context.Context, p *CalendarCreateParams) (*EventWrite, error)
	// Update implements calendar.update. Change an event, an occurrence, or a
	// series from an occurrence on (ADR-0031). An event the user is invited to
	// takes only alarms. A change that tells invitees needs notify (ADR-0035).
	Update(ctx context.Context, p *CalendarUpdateParams) (*EventWrite, error)
	// Delete implements calendar.delete. Delete an event, an occurrence, or a
	// series from an occurrence on.
	Delete(ctx context.Context, p *CalendarDeleteParams) (*EventWrite, error)
	// Restore implements calendar.restore. Undo a create, update or delete by
	// writing back what it replaced (ADR-0032).
	Restore(ctx context.Context, p *CalendarRestoreParams) error
}

CalendarService: Events from the accounts' calendars, their occurrences, invitations and reminders (docs/design/pim.md, ADR-0018, ADR-0019), and their edits (ADR-0030 to ADR-0033, ADR-0035).

type CalendarSnoozeParams

type CalendarSnoozeParams struct {
	IDs   []string  `json:"ids"`
	Until time.Time `json:"until"`
}

CalendarSnoozeParams holds the params of calendar.snooze.

type CalendarUpdateParams

type CalendarUpdateParams struct {
	ID int64 `json:"id"`
	// The occurrence, for an event that repeats.
	RecurrenceID *string `json:"recurrenceId,omitzero"`
	// Required with recurrenceId.
	Scope  *EventScope `json:"scope,omitzero"`
	Fields EventFields `json:"fields"`
	// true sends what the change tells invitees; required when it tells any
	// (notifyRequired). false is invalidParams where the server cannot be kept
	// quiet (ADR-0035).
	Notify *bool `json:"notify,omitzero"`
}

CalendarUpdateParams holds the params of calendar.update.

type Caller

type Caller struct {
	Kind        CallerKind
	Login       string
	NodeName    string
	DisplayName string
	Session     string
	Token       string
	Scope       Scope
}

Caller is who a connection serves (docs/specs/lodge-app.md). Login, NodeName, DisplayName and Session come from lodge for a session; Token and Scope for an agent, whose scope the engine enforces.

func CallerFrom

func CallerFrom(ctx context.Context) Caller

CallerFrom returns the caller a request arrived for: a local caller when none was set.

type CallerKind

type CallerKind string

CallerKind: Who a connection serves (docs/specs/lodge-app.md). A method a connection's caller may not use answers methodNotFound.

const (
	// maild's private socket: mailctl, and the app on the same machine.
	CallerKindLocal CallerKind = "local"
	// A browser session through lodge's /app/mail/api.
	CallerKindSession CallerKind = "session"
	// An MCP session through lodge's /mcp/mail.
	CallerKindAgent CallerKind = "agent"
)

func (CallerKind) Valid

func (v CallerKind) Valid() bool

Valid reports whether v is one of the declared values.

type Client

type Client struct {
	*jsonrpc.Client[ErrorCode]
}

Client is a maild connection. It is safe for concurrent use; calls are multiplexed by request ID.

func NewClient

func NewClient(conn net.Conn) *Client

NewClient starts a client on an established connection. The caller must call rpc.hello before anything else; Dial does.

func (*Client) Account

func (c *Client) Account() AccountClient

Account returns the account methods.

func (*Client) Address

func (c *Client) Address() AddressClient

Address returns the address methods.

func (*Client) Block

func (c *Client) Block() BlockClient

Block returns the block methods.

func (*Client) Calendar

func (c *Client) Calendar() CalendarClient

Calendar returns the calendar methods.

func (*Client) Draft

func (c *Client) Draft() DraftClient

Draft returns the draft methods.

func (*Client) Events

func (c *Client) Events() EventsClient

Events returns the events methods.

func (*Client) Identity

func (c *Client) Identity() IdentityClient

Identity returns the identity methods.

func (*Client) Mailbox

func (c *Client) Mailbox() MailboxClient

Mailbox returns the mailbox methods.

func (*Client) Message

func (c *Client) Message() MessageClient

Message returns the message methods.

func (*Client) Oauth

func (c *Client) Oauth() OauthClient

Oauth returns the oauth methods.

func (*Client) Outbox

func (c *Client) Outbox() OutboxClient

Outbox returns the outbox methods.

func (*Client) People

func (c *Client) People() PeopleClient

People returns the people methods.

func (*Client) RPC

func (c *Client) RPC() RPCClient

RPC returns the rpc methods.

func (*Client) Rule

func (c *Client) Rule() RuleClient

Rule returns the rule methods.

func (*Client) Settings

func (c *Client) Settings() SettingsClient

Settings returns the settings methods.

func (*Client) Smart

func (c *Client) Smart() SmartClient

Smart returns the smart methods.

func (*Client) Sync

func (c *Client) Sync() SyncClient

Sync returns the sync methods.

func (*Client) Tasks

func (c *Client) Tasks() TasksClient

Tasks returns the tasks methods.

func (*Client) Thread

func (c *Client) Thread() ThreadClient

Thread returns the thread methods.

func (*Client) View

func (c *Client) View() ViewClient

View returns the view methods.

func (*Client) Vip

func (c *Client) Vip() VipClient

Vip returns the vip methods.

type Collection

type Collection struct {
	ID        int64          `json:"id"`
	AccountID int64          `json:"accountId"`
	Kind      CollectionKind `json:"kind"`
	Name      string         `json:"name"`
	// #rrggbb, or empty for the module's default.
	Color string `json:"color"`
	// Holds events.
	Events bool `json:"events"`
	// Holds tasks: a task list, or a calendar with VTODO.
	Tasks bool `json:"tasks"`
	// The server refuses changes, or the account is read-only.
	ReadOnly bool `json:"readOnly"`
	// Synced and shown.
	Enabled bool `json:"enabled"`
	// Where the account's new contacts, events or tasks go.
	IsDefault bool `json:"isDefault"`
	// A calendar whose server tells invitees about the events Frostmail writes,
	// so its events may have invitees (ADR-0035).
	Invites bool `json:"invites"`
}

Collection: An address book, calendar or task list.

type CollectionCheck

type CollectionCheck struct {
	CollectionID int64  `json:"collectionId"`
	Name         string `json:"name"`
	// Objects on the server.
	Server int64 `json:"server"`
	// Objects stored locally.
	Local int64 `json:"local"`
	// Server hrefs with no local object (at most 20).
	MissingLocally []string `json:"missingLocally"`
	// Local hrefs the server does not have (at most 20), leaving out changes
	// waiting to be written.
	MissingOnServer []string `json:"missingOnServer"`
	// Objects whose ETag differs, with the same exception.
	EtagDiffs int64 `json:"etagDiffs"`
}

CollectionCheck: How one synced address book, calendar or task list compares with the server.

type CollectionKind

type CollectionKind string

CollectionKind: What a collection holds.

const (
	// A CardDAV address book.
	CollectionKindAddressbook CollectionKind = "addressbook"
	// A CalDAV calendar, holding events, tasks or both.
	CollectionKindCalendar CollectionKind = "calendar"
	// A Google Tasks list.
	CollectionKindTasklist CollectionKind = "tasklist"
)

func (CollectionKind) Valid

func (v CollectionKind) Valid() bool

Valid reports whether v is one of the declared values.

type Condition

type Condition struct {
	Field ConditionField `json:"field"`
	Op    ConditionOp    `json:"op"`
	// Empty for ops that take none.
	Value string `json:"value"`
}

Condition: One condition, as Mail.app's editors show it.

type ConditionField

type ConditionField string

ConditionField: What a condition looks at; docs/design/organize.md lists the ops and values each takes.

const (
	// The sender.
	ConditionFieldFrom ConditionField = "from"
	// An address or name in To.
	ConditionFieldTo ConditionField = "to"
	// An address or name in Cc.
	ConditionFieldCc ConditionField = "cc"
	// Any recipient, To or Cc, by the words of the search index.
	ConditionFieldRecipient ConditionField = "recipient"
	// One of the account's own addresses is in To.
	ConditionFieldTome ConditionField = "tome"
	// One of the account's own addresses is in Cc.
	ConditionFieldCcme    ConditionField = "ccme"
	ConditionFieldSubject ConditionField = "subject"
	// Anything the search index holds: subject, addresses, body and attachment
	// names.
	ConditionFieldContent ConditionField = "content"
	// An attachment's file name.
	ConditionFieldFilename ConditionField = "filename"
	// The List-Id header.
	ConditionFieldListid ConditionField = "listid"
	// Account IDs.
	ConditionFieldAccount ConditionField = "account"
	// Mailbox IDs.
	ConditionFieldMailbox ConditionField = "mailbox"
	// Mailbox roles, in any account.
	ConditionFieldRole ConditionField = "role"
	// The arrival date.
	ConditionFieldReceived ConditionField = "received"
	// The Date header.
	ConditionFieldSent    ConditionField = "sent"
	ConditionFieldUnread  ConditionField = "unread"
	ConditionFieldFlagged ConditionField = "flagged"
	// Has attachments.
	ConditionFieldAttachments ConditionField = "attachments"
	// The flag color, 1-7.
	ConditionFieldColor ConditionField = "color"
	// The sender is a VIP.
	ConditionFieldVip ConditionField = "vip"
	// The sender is in People.
	ConditionFieldContact ConditionField = "contact"
	// A Remind Me reminder is pending.
	ConditionFieldReminder ConditionField = "reminder"
)

func (ConditionField) Valid

func (v ConditionField) Valid() bool

Valid reports whether v is one of the declared values.

type ConditionMatch

type ConditionMatch string

ConditionMatch: How a list of conditions combines (docs/design/organize.md).

const (
	// Every condition must hold.
	ConditionMatchAll ConditionMatch = "all"
	// At least one condition must hold.
	ConditionMatchAny ConditionMatch = "any"
)

func (ConditionMatch) Valid

func (v ConditionMatch) Valid() bool

Valid reports whether v is one of the declared values.

type ConditionOp

type ConditionOp string

ConditionOp: How a condition compares; which fields take which ops is in docs/design/organize.md.

const (
	// Every word of the value, as prefixes; a quoted value is a phrase.
	ConditionOpContains ConditionOp = "contains"
	// Not contains; also true when the field is empty.
	ConditionOpNotcontains ConditionOp = "notcontains"
	// Equal, ignoring case; true or false for yes-or-no fields.
	ConditionOpIs ConditionOp = "is"
	// Not equal; also true when the field is empty.
	ConditionOpIsnot  ConditionOp = "isnot"
	ConditionOpBegins ConditionOp = "begins"
	ConditionOpEnds   ConditionOp = "ends"
	// One of a comma-separated list of IDs, roles or colors.
	ConditionOpAnyof     ConditionOp = "anyof"
	ConditionOpToday     ConditionOp = "today"
	ConditionOpYesterday ConditionOp = "yesterday"
	// Since Monday.
	ConditionOpThisweek  ConditionOp = "thisweek"
	ConditionOpThismonth ConditionOp = "thismonth"
	ConditionOpThisyear  ConditionOp = "thisyear"
	// Since the start of the day N units ago; the value is N and d, w, m or y,
	// such as 7d.
	ConditionOpWithin    ConditionOp = "within"
	ConditionOpNotwithin ConditionOp = "notwithin"
	// That day, YYYY-MM-DD.
	ConditionOpOn ConditionOp = "on"
	// From that day, YYYY-MM-DD.
	ConditionOpSince ConditionOp = "since"
	// Before that day, YYYY-MM-DD.
	ConditionOpBefore ConditionOp = "before"
)

func (ConditionOp) Valid

func (v ConditionOp) Valid() bool

Valid reports whether v is one of the declared values.

type Conditions

type Conditions struct {
	Match      ConditionMatch `json:"match"`
	Conditions []Condition    `json:"conditions"`
}

Conditions: Conditions, combined by match. An empty list matches every message.

type Conn

type Conn interface {
	// Notify sends a transient event to this connection only.
	Notify(Event) error
	// Done is closed when the connection ends.
	Done() <-chan struct{}
}

Conn is the client connection a request arrived on, for services that keep per-connection state, such as views.

func ConnFrom

func ConnFrom(ctx context.Context) Conn

ConnFrom returns the connection a request arrived on, or nil.

type Contact

type Contact struct {
	ID           int64  `json:"id"`
	CollectionID int64  `json:"collectionId"`
	AccountID    int64  `json:"accountId"`
	DisplayName  string `json:"displayName"`
	GivenName    string `json:"givenName"`
	FamilyName   string `json:"familyName"`
	Nickname     string `json:"nickname"`
	Organization string `json:"organization"`
	Title        string `json:"title"`
	// Each address once, compared trimmed and without case, though the vCard may
	// give it twice.
	Emails    []LabeledValue  `json:"emails"`
	Phones    []LabeledValue  `json:"phones"`
	Addresses []PostalAddress `json:"addresses"`
	URLs      []LabeledValue  `json:"urls"`
	// YYYY-MM-DD, or --MM-DD without a year; empty when unknown.
	Birthday string `json:"birthday"`
	Note     string `json:"note"`
	ReadOnly bool   `json:"readOnly"`
}

Contact: One vCard of a person, from one address book, read from its source.

type ContactCard

type ContactCard struct {
	// Lowercased.
	Email string `json:"email"`
	// The person's name, else the name last seen with the address in mail; may be
	// empty.
	Name string `json:"name"`
	// Absent when no contact has the address.
	Person *Person `json:"person,omitzero"`
	// The newest messages from or to the address, at most 5.
	Recent []MessageSummary `json:"recent"`
	// The next occurrences with the address as organizer or attendee, within 30
	// days, at most 5.
	Upcoming []Occurrence `json:"upcoming"`
	// No contact has the address and an address book can take one: Add to
	// Contacts is offered.
	CanAdd bool `json:"canAdd"`
}

ContactCard: What the app shows for an email address in mail.

type ContactFields

type ContactFields struct {
	GivenName    *string         `json:"givenName,omitzero"`
	FamilyName   *string         `json:"familyName,omitzero"`
	Nickname     *string         `json:"nickname,omitzero"`
	Organization *string         `json:"organization,omitzero"`
	Title        *string         `json:"title,omitzero"`
	Emails       []LabeledValue  `json:"emails,omitzero"`
	Phones       []LabeledValue  `json:"phones,omitzero"`
	Addresses    []PostalAddress `json:"addresses,omitzero"`
	URLs         []LabeledValue  `json:"urls,omitzero"`
	// YYYY-MM-DD, --MM-DD, or empty to clear.
	Birthday *string `json:"birthday,omitzero"`
	Note     *string `json:"note,omitzero"`
}

ContactFields: What an edit sets; absent fields keep their values, and a list replaces the whole list.

type ContactWrite

type ContactWrite struct {
	ContactID int64 `json:"contactId"`
	// The contact's person as changed; absent when no contact of theirs is left.
	Person *Person `json:"person,omitzero"`
	// For people.restore, within a day.
	RestoreID string `json:"restoreId"`
}

ContactWrite: What a change wrote, and how to undo it (ADR-0032).

type Discovery

type Discovery struct {
	Kind   AccountKind     `json:"kind"`
	Source DiscoverySource `json:"source"`
	// The sign-in kinds the provider accepts, preferred first.
	Auth []AuthKind    `json:"auth"`
	IMAP *ServerConfig `json:"imap,omitzero"`
	SMTP *ServerConfig `json:"smtp,omitzero"`
}

Discovery: Server settings found for an address.

type DiscoverySource

type DiscoverySource string

DiscoverySource: Where account.discover found server settings.

const (
	// Frostmail's own profile for the provider (Gmail, iCloud, Outlook.com).
	DiscoverySourceProfile DiscoverySource = "profile"
	// The domain's Mozilla autoconfig file.
	DiscoverySourceAutoconfig DiscoverySource = "autoconfig"
	// Thunderbird's ISP database.
	DiscoverySourceIspdb DiscoverySource = "ispdb"
	// The domain's RFC 6186 SRV records.
	DiscoverySourceSrv DiscoverySource = "srv"
	// Nothing found; the user enters the servers.
	DiscoverySourceNone DiscoverySource = "none"
)

func (DiscoverySource) Valid

func (v DiscoverySource) Valid() bool

Valid reports whether v is one of the declared values.

type Draft

type Draft struct {
	ID          int64             `json:"id"`
	AccountID   int64             `json:"accountId"`
	Content     DraftContent      `json:"content"`
	Attachments []DraftAttachment `json:"attachments"`
	// The message this draft replies to or forwards.
	SourceID  *int64    `json:"sourceId,omitzero"`
	Kind      DraftKind `json:"kind"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Draft: A message being written.

type DraftAttachDataParams

type DraftAttachDataParams struct {
	ID int64 `json:"id"`
	// The file's name, without a directory.
	Filename string `json:"filename"`
	// The whole file's bytes; the draft's attachments may total 25 MB.
	Size int64 `json:"size"`
	// Where this chunk starts: 0, then the last result's received.
	Offset int64 `json:"offset"`
	// The chunk's bytes, base64 (standard alphabet, padded), 1 byte to 4 MiB
	// decoded.
	Data string `json:"data"`
	// The upload, for every chunk after the first.
	UploadID *string `json:"uploadId,omitzero"`
}

DraftAttachDataParams holds the params of draft.attachData.

type DraftAttachParams

type DraftAttachParams struct {
	ID int64 `json:"id"`
	// An absolute path on this machine.
	Path string `json:"path"`
}

DraftAttachParams holds the params of draft.attach.

type DraftAttachment

type DraftAttachment struct {
	ID       int64  `json:"id"`
	Filename string `json:"filename"`
	// Lowercase type/subtype.
	ContentType string `json:"contentType"`
	// Bytes.
	Size int64 `json:"size"`
}

DraftAttachment: A file attached to a draft, stored by maild.

type DraftChanged

type DraftChanged struct {
	ID        int64 `json:"id"`
	AccountID int64 `json:"accountId"`
	Deleted   bool  `json:"deleted"`
}

DraftChanged: A draft was created, changed or deleted.

func (DraftChanged) Durable

func (DraftChanged) Durable() bool

Durable reports whether DraftChanged is kept in the changes log.

func (DraftChanged) EventName

func (DraftChanged) EventName() string

EventName is the wire name of DraftChanged.

type DraftClient

type DraftClient struct {
	// contains filtered or unexported fields
}

DraftClient calls the draft methods; it implements DraftService.

func (DraftClient) Attach

Attach calls draft.attach.

func (DraftClient) AttachData

AttachData calls draft.attachData.

func (DraftClient) Create

func (x DraftClient) Create(ctx context.Context, p *DraftCreateParams) (*Draft, error)

Create calls draft.create.

func (DraftClient) Delete

Delete calls draft.delete.

func (DraftClient) Detach

Detach calls draft.detach.

func (DraftClient) Get

func (x DraftClient) Get(ctx context.Context, p *DraftGetParams) (*Draft, error)

Get calls draft.get.

func (DraftClient) List

func (x DraftClient) List(ctx context.Context, p *DraftListParams) ([]Draft, error)

List calls draft.list.

func (DraftClient) Open

func (x DraftClient) Open(ctx context.Context, p *DraftOpenParams) (*Draft, error)

Open calls draft.open.

func (DraftClient) Send

Send calls draft.send.

func (DraftClient) Unsaved

func (x DraftClient) Unsaved(ctx context.Context, p *DraftUnsavedParams) ([]Draft, error)

Unsaved calls draft.unsaved.

func (DraftClient) Update

func (x DraftClient) Update(ctx context.Context, p *DraftUpdateParams) (*Draft, error)

Update calls draft.update.

type DraftContent

type DraftContent struct {
	IdentityID int64     `json:"identityId"`
	To         []Address `json:"to"`
	Cc         []Address `json:"cc"`
	Bcc        []Address `json:"bcc"`
	Subject    string    `json:"subject"`
	// The body as the editor's HTML.
	HTML string `json:"html"`
}

DraftContent: What a compose window edits.

type DraftCreateParams

type DraftCreateParams struct {
	Kind      DraftKind `json:"kind"`
	AccountID *int64    `json:"accountId,omitzero"`
	// Required for reply, replyall and forward.
	SourceID *int64 `json:"sourceId,omitzero"`
	// A new message's recipients, such as the person a contact card writes to.
	To []Address `json:"to,omitzero"`
}

DraftCreateParams holds the params of draft.create.

type DraftDeleteParams

type DraftDeleteParams struct {
	ID int64 `json:"id"`
}

DraftDeleteParams holds the params of draft.delete.

type DraftDetachParams

type DraftDetachParams struct {
	ID           int64 `json:"id"`
	AttachmentID int64 `json:"attachmentId"`
}

DraftDetachParams holds the params of draft.detach.

type DraftGetParams

type DraftGetParams struct {
	ID int64 `json:"id"`
}

DraftGetParams holds the params of draft.get.

type DraftKind

type DraftKind string

DraftKind: How a new draft starts.

const (
	// An empty message with the identity's signature.
	DraftKindNew DraftKind = "new"
	// A reply to the source's sender.
	DraftKindReply DraftKind = "reply"
	// A reply to the sender and every other recipient but the account's own
	// addresses.
	DraftKindReplyall DraftKind = "replyall"
	// The source as quoted text with its attachments.
	DraftKindForward DraftKind = "forward"
	// Forward as Attachment: the source attached whole, as an .eml file. The
	// draft is then a forward.
	DraftKindAttached DraftKind = "attached"
)

func (DraftKind) Valid

func (v DraftKind) Valid() bool

Valid reports whether v is one of the declared values.

type DraftListParams

type DraftListParams struct {
	AccountID *int64 `json:"accountId,omitzero"`
}

DraftListParams holds the params of draft.list.

type DraftOpenParams

type DraftOpenParams struct {
	MessageID int64 `json:"messageId"`
}

DraftOpenParams holds the params of draft.open.

type DraftSendParams

type DraftSendParams struct {
	ID int64 `json:"id"`
	// Send Later: a time past the undo delay queues the message scheduled, with
	// this time as its Date; an earlier one sends it after the undo delay.
	SendAt *time.Time `json:"sendAt,omitzero"`
}

DraftSendParams holds the params of draft.send.

type DraftService

type DraftService interface {
	// Create implements draft.create. Start a draft: a new message in the account
	// (or the first account), or a reply, reply-all or forward of a message.
	Create(ctx context.Context, p *DraftCreateParams) (*Draft, error)
	// Open implements draft.open. Turn a message in a Drafts mailbox into a
	// draft, or return the draft it already is.
	Open(ctx context.Context, p *DraftOpenParams) (*Draft, error)
	// Get implements draft.get. One draft.
	Get(ctx context.Context, p *DraftGetParams) (*Draft, error)
	// List implements draft.list. Drafts, most recently changed first.
	List(ctx context.Context, p *DraftListParams) ([]Draft, error)
	// Unsaved implements draft.unsaved. The drafts no stored message holds yet
	// (none of the account's has their Message-ID) and the Outbox does not hold,
	// most recently changed first: those a Drafts mailbox and All Drafts list as
	// not yet saved, so no draft is out of sight before its server copy arrives
	// (with sync off, offline, or within the quiet period; docs/design/send.md).
	Unsaved(ctx context.Context, p *DraftUnsavedParams) ([]Draft, error)
	// Update implements draft.update. Replace a draft's content; maild stores it
	// at once and updates the server copy later.
	Update(ctx context.Context, p *DraftUpdateParams) (*Draft, error)
	// Attach implements draft.attach. Attach a local file; maild copies it, so
	// later changes to the file do not matter.
	Attach(ctx context.Context, p *DraftAttachParams) (*DraftAttachment, error)
	// AttachData implements draft.attachData. Attach a file by its bytes, for a
	// client that cannot name a path on maild's machine, such as a browser
	// through lodge: in chunks, in order. The first chunk (offset 0, without
	// uploadId) starts an upload of size bytes named filename; each later one
	// names the upload and the offset it continues at. The chunk that completes
	// size attaches the file as draft.attach does, and the result carries it.
	// maild checks the name and the size, names the type from the name and the
	// bytes, and discards an upload its connection leaves unfinished, or that
	// sends nothing for 10 minutes.
	AttachData(ctx context.Context, p *DraftAttachDataParams) (*DraftUpload, error)
	// Detach implements draft.detach. Remove an attachment from a draft.
	Detach(ctx context.Context, p *DraftDetachParams) error
	// Delete implements draft.delete. Discard a draft, and its server copy.
	Delete(ctx context.Context, p *DraftDeleteParams) error
	// Send implements draft.send. Queue a draft for sending after the undo delay,
	// or at sendAt (Send Later). Fails with invalidParams when it has no
	// recipients, an address does not parse, or it is too large.
	Send(ctx context.Context, p *DraftSendParams) (*OutboxItem, error)
}

DraftService: Drafts: messages being written. maild stores a draft at once on every update and keeps a copy in the account's Drafts mailbox; draft.send hands it to the outbox (docs/design/send.md).

type DraftUnsavedParams

type DraftUnsavedParams struct {
	AccountID *int64 `json:"accountId,omitzero"`
}

DraftUnsavedParams holds the params of draft.unsaved.

type DraftUpdateParams

type DraftUpdateParams struct {
	ID      int64        `json:"id"`
	Content DraftContent `json:"content"`
}

DraftUpdateParams holds the params of draft.update.

type DraftUpload

type DraftUpload struct {
	// Names the upload in its later chunks.
	UploadID string `json:"uploadId"`
	// The bytes maild holds: the next chunk's offset.
	Received int64 `json:"received"`
	// The attachment, once the last chunk is in.
	Attachment *DraftAttachment `json:"attachment,omitzero"`
}

DraftUpload: An attachment arriving in chunks (draft.attachData).

type Error

type Error = jsonrpc.Error[ErrorCode]

Error is a JSON-RPC error object. Handlers return one to choose the code; any other error reaches the client as CodeInternal.

func AuthRequired

func AuthRequired(format string, args ...any) *Error

AuthRequired returns an error with CodeAuthRequired.

func Conflict

func Conflict(format string, args ...any) *Error

Conflict returns an error with CodeConflict.

func Errorf

func Errorf(code ErrorCode, format string, args ...any) *Error

Errorf returns an *Error with a formatted message.

func Internal

func Internal(format string, args ...any) *Error

Internal returns an error with CodeInternal.

func InvalidParams

func InvalidParams(format string, args ...any) *Error

InvalidParams returns an error with CodeInvalidParams.

func InvalidRequest

func InvalidRequest(format string, args ...any) *Error

InvalidRequest returns an error with CodeInvalidRequest.

func MethodNotFound

func MethodNotFound(format string, args ...any) *Error

MethodNotFound returns an error with CodeMethodNotFound.

func NotFound

func NotFound(format string, args ...any) *Error

NotFound returns an error with CodeNotFound.

func NotReady

func NotReady(format string, args ...any) *Error

NotReady returns an error with CodeNotReady.

func NotifyRequired

func NotifyRequired(format string, args ...any) *Error

NotifyRequired returns an error with CodeNotifyRequired.

func ParseError

func ParseError(format string, args ...any) *Error

ParseError returns an error with CodeParseError.

func ProtocolMismatch

func ProtocolMismatch(format string, args ...any) *Error

ProtocolMismatch returns an error with CodeProtocolMismatch.

func Unavailable

func Unavailable(format string, args ...any) *Error

Unavailable returns an error with CodeUnavailable.

type ErrorCode

type ErrorCode int

ErrorCode is a JSON-RPC error code; the generated constants name them.

const (
	// The request is not valid JSON.
	CodeParseError ErrorCode = -32700
	// The request is not a valid JSON-RPC 2.0 request object.
	CodeInvalidRequest ErrorCode = -32600
	// The method does not exist.
	CodeMethodNotFound ErrorCode = -32601
	// The params are missing, unknown or invalid.
	CodeInvalidParams ErrorCode = -32602
	// The server failed; the message says why.
	CodeInternal ErrorCode = -32603
	// The referenced entity does not exist.
	CodeNotFound ErrorCode = 1001
	// The request conflicts with existing state, such as a duplicate account.
	CodeConflict ErrorCode = 1002
	// The server does not speak the client's protocol major version.
	CodeProtocolMismatch ErrorCode = 1003
	// The connection has not completed rpc.hello.
	CodeNotReady ErrorCode = 1004
	// The operation cannot run now, for example while offline; retrying later can
	// succeed.
	CodeUnavailable ErrorCode = 1005
	// The account's credentials were rejected or have expired; the user must sign
	// in again.
	CodeAuthRequired ErrorCode = 1006
	// The change would tell invitees: ask the user, then repeat it with notify
	// (ADR-0035). The error's data is an InviteNotice.
	CodeNotifyRequired ErrorCode = 1007
)

Error codes. JSON-RPC 2.0 defines the negative codes.

func (ErrorCode) String

func (c ErrorCode) String() string

String is the code's schema name.

type Event

type Event = jsonrpc.Event

Event is a generated event type, and EventEnvelope the params of an "event" notification.

func DecodeEvent

func DecodeEvent(name string, data jsontext.Value) (Event, error)

DecodeEvent decodes the data of the named event.

type EventEnvelope

type EventEnvelope = jsonrpc.EventEnvelope

Event is a generated event type, and EventEnvelope the params of an "event" notification.

func NewEnvelope

func NewEnvelope(seq int64, ev Event) (EventEnvelope, error)

NewEnvelope encodes ev for delivery.

type EventFields

type EventFields struct {
	Summary  *string `json:"summary,omitzero"`
	Location *string `json:"location,omitzero"`
	// Plain text.
	Description *string    `json:"description,omitzero"`
	AllDay      *bool      `json:"allDay,omitzero"`
	Start       *time.Time `json:"start,omitzero"`
	// Exclusive; after start.
	End *time.Time `json:"end,omitzero"`
	// The IANA zone the times are written in (ADR-0033).
	TimeZone *string `json:"timeZone,omitzero"`
	// All-day: the first day, YYYY-MM-DD.
	StartDate *string `json:"startDate,omitzero"`
	// All-day: the day after the last.
	EndDate *string `json:"endDate,omitzero"`
	// The RRULE value, such as FREQ=WEEKLY;BYDAY=MO,WE; empty for no repeat.
	Rrule *string `json:"rrule,omitzero"`
	// The user's alerts, as minutes before the start (negative: after); replaces
	// them all.
	Alarms []int64 `json:"alarms,omitzero"`
	// Does not count as busy.
	Transparent *bool `json:"transparent,omitzero"`
	// Move the event to this calendar (ADR-0030); not an event with invitees
	// (ADR-0035).
	CalendarID *int64 `json:"calendarId,omitzero"`
	// The invitees, replacing them all; empty removes them. Only in a calendar
	// that invites (Collection.invites); the user's own addresses are left out
	// (ADR-0035).
	Attendees []Invitee `json:"attendees,omitzero"`
}

EventFields: What an edit sets; absent fields keep their values. A timed event has start, end and timeZone; an all-day one has startDate and endDate.

type EventScope

type EventScope string

EventScope: What a change to an occurrence of a series changes (ADR-0031).

const (
	// This occurrence only: an override, or an EXDATE when deleting.
	EventScopeThis EventScope = "this"
	// This occurrence and the ones after it: the series splits.
	EventScopeFuture EventScope = "future"
	// The whole series: the master.
	EventScopeAll EventScope = "all"
)

func (EventScope) Valid

func (v EventScope) Valid() bool

Valid reports whether v is one of the declared values.

type EventStatus

type EventStatus string

EventStatus: An event's STATUS.

const (
	EventStatusConfirmed EventStatus = "confirmed"
	EventStatusTentative EventStatus = "tentative"
	EventStatusCancelled EventStatus = "cancelled"
)

func (EventStatus) Valid

func (v EventStatus) Valid() bool

Valid reports whether v is one of the declared values.

type EventWrite

type EventWrite struct {
	// The event or occurrence as changed; absent after a delete.
	Event *CalendarEvent `json:"event,omitzero"`
	// For calendar.restore, within a day.
	RestoreID string `json:"restoreId"`
}

EventWrite: What a change wrote, and how to undo it (ADR-0032).

type EventsClient

type EventsClient struct {
	// contains filtered or unexported fields
}

EventsClient calls the events methods; it implements EventsService.

func (EventsClient) Subscribe

Subscribe calls events.subscribe.

type EventsService

type EventsService interface {
	// Subscribe implements events.subscribe. Start receiving events on this
	// connection. Durable events after sinceSeq are replayed before live events.
	Subscribe(ctx context.Context, p *EventsSubscribeParams) (*Subscription, error)
}

EventsService: Change notifications. After events.subscribe, the server sends JSON-RPC notifications with method "event" on the same connection. Durable events carry a sequence number and are kept in the changes log, so a client that reconnects can resume from the last sequence number it saw.

type EventsSubscribeParams

type EventsSubscribeParams struct {
	// Replay durable events after this sequence number. Omit to receive live
	// events only.
	SinceSeq *int64 `json:"sinceSeq,omitzero"`
}

EventsSubscribeParams holds the params of events.subscribe.

type FlagChanges

type FlagChanges struct {
	Seen      *bool  `json:"seen,omitzero"`
	Flagged   *bool  `json:"flagged,omitzero"`
	Answered  *bool  `json:"answered,omitzero"`
	FlagColor *int64 `json:"flagColor,omitzero"`
}

FlagChanges: Flags to set or clear; omitted fields keep their values.

type Flags

type Flags struct {
	Seen      bool `json:"seen"`
	Flagged   bool `json:"flagged"`
	Answered  bool `json:"answered"`
	Forwarded bool `json:"forwarded"`
	Draft     bool `json:"draft"`
	// 0 for none, 1-7 for Mail.app's flag colors (stored as $MailFlagBit0-2).
	FlagColor int64 `json:"flagColor"`
}

Flags: The flags clients show and change.

type Frame

type Frame = jsonrpc.Frame[ErrorCode]

Frame is one JSON-RPC 2.0 message in either direction.

type Hello

type Hello struct {
	// Protocol major version the server speaks.
	Protocol int64 `json:"protocol"`
	// Server name and version, for logs.
	Server string `json:"server"`
	// The connection's caller; absent from a maild older than callers, which
	// serves local only.
	Caller *CallerKind `json:"caller,omitzero"`
	// A session's tailnet login, from lodge.
	Login *string `json:"login,omitzero"`
	// A session's tailnet node name, from lodge.
	NodeName *string `json:"nodeName,omitzero"`
	// A session's display name, when lodge has one.
	DisplayName *string `json:"displayName,omitzero"`
}

Hello: Server identity, the negotiated protocol, and who the connection serves.

type ITIPMethod

type ITIPMethod string

ITIPMethod: What an invitation message asks (iTIP METHOD).

const (
	// An invitation, or an update of one.
	ITIPMethodRequest ITIPMethod = "request"
	// The organizer cancelled the event or the user's place in it.
	ITIPMethodCancel ITIPMethod = "cancel"
	// An attendee answered the user's invitation.
	ITIPMethodReply ITIPMethod = "reply"
	// An event to add; no answer expected.
	ITIPMethodPublish ITIPMethod = "publish"
	// ADD, REFRESH, COUNTER or DECLINECOUNTER: shown, not acted on.
	ITIPMethodOther ITIPMethod = "other"
)

func (ITIPMethod) Valid

func (v ITIPMethod) Valid() bool

Valid reports whether v is one of the declared values.

type Identity

type Identity struct {
	ID            int64  `json:"id"`
	AccountID     int64  `json:"accountId"`
	Name          string `json:"name"`
	Email         string `json:"email"`
	ReplyTo       string `json:"replyTo"`
	SignatureHTML string `json:"signatureHtml"`
	IsDefault     bool   `json:"isDefault"`
}

Identity: One From address of an account.

type IdentityClient

type IdentityClient struct {
	// contains filtered or unexported fields
}

IdentityClient calls the identity methods; it implements IdentityService.

func (IdentityClient) Create

Create calls identity.create.

func (IdentityClient) Delete

Delete calls identity.delete.

func (IdentityClient) List

List calls identity.list.

func (IdentityClient) Update

Update calls identity.update.

type IdentityCreateParams

type IdentityCreateParams struct {
	AccountID int64  `json:"accountId"`
	Email     string `json:"email"`
	// Default: the name of the account's default identity.
	Name *string `json:"name,omitzero"`
}

IdentityCreateParams holds the params of identity.create.

type IdentityDeleteParams

type IdentityDeleteParams struct {
	ID int64 `json:"id"`
}

IdentityDeleteParams holds the params of identity.delete.

type IdentityListParams

type IdentityListParams struct {
	AccountID *int64 `json:"accountId,omitzero"`
}

IdentityListParams holds the params of identity.list.

type IdentityService

type IdentityService interface {
	// List implements identity.list. Identities, default first per account.
	List(ctx context.Context, p *IdentityListParams) ([]Identity, error)
	// Update implements identity.update. Change an identity's name, Reply-To or
	// signature.
	Update(ctx context.Context, p *IdentityUpdateParams) (*Identity, error)
	// Create implements identity.create. Add an address the account also sends
	// and receives as, such as an alias or a custom domain the provider delivers
	// to it. Invitations to it can be answered from the account. account.changed
	// follows.
	Create(ctx context.Context, p *IdentityCreateParams) (*Identity, error)
	// Delete implements identity.delete. Remove an address added with
	// identity.create; drafts that used it move to the account's default
	// identity. account.changed follows.
	Delete(ctx context.Context, p *IdentityDeleteParams) error
}

IdentityService: The addresses an account sends as, with their signatures.

type IdentityUpdateParams

type IdentityUpdateParams struct {
	ID            int64   `json:"id"`
	Name          *string `json:"name,omitzero"`
	ReplyTo       *string `json:"replyTo,omitzero"`
	SignatureHTML *string `json:"signatureHtml,omitzero"`
}

IdentityUpdateParams holds the params of identity.update.

type Invitation

type Invitation struct {
	Method ITIPMethod `json:"method"`
	// The event as the message describes it; id is 0 when it is not stored.
	Event CalendarEvent `json:"event"`
	// The stored event with the message's UID, when there is one.
	EventID *int64 `json:"eventId,omitzero"`
	// Request and cancel: the organizer. Reply: the attendee who answered.
	From *Attendee `json:"from,omitzero"`
	// The user's current answer to the stored event or, before it is stored, to
	// the message.
	Answer *PartStat `json:"answer,omitzero"`
	// A request the user is invited to, not outdated, in an account that can
	// write.
	CanRespond bool `json:"canRespond"`
	// The stored event has a later SEQUENCE than the message.
	Outdated bool `json:"outdated"`
	// Busy occurrences overlapping the event's first occurrence.
	Conflicts []Occurrence `json:"conflicts"`
	// The occurrences just before and after it on the same day.
	Adjacent []Occurrence `json:"adjacent"`
}

Invitation: An iTIP message in mail, matched against the stored events (ADR-0019).

type InviteNotice

type InviteNotice struct {
	Kind NoticeKind `json:"kind"`
	// How many invitees it tells.
	Count int64 `json:"count"`
}

InviteNotice: What a change would tell invitees; notifyRequired's data (ADR-0035).

type Invitee

type Invitee struct {
	Email string  `json:"email"`
	Name  *string `json:"name,omitzero"`
	// required (the default) or optional.
	Role *AttendeeRole `json:"role,omitzero"`
}

Invitee: An invitee to set on an event the user organizes (ADR-0035).

type LabeledValue

type LabeledValue struct {
	// home, work, mobile, other, or the card's own label; may be empty.
	Label string `json:"label"`
	Value string `json:"value"`
}

LabeledValue: An email address, phone number or URL with its label.

type Mailbox

type Mailbox struct {
	ID        int64 `json:"id"`
	AccountID int64 `json:"accountId"`
	// Full server path, decoded from modified UTF-7.
	Path string `json:"path"`
	// The last path component, for display.
	Name string `json:"name"`
	// The server's hierarchy delimiter; empty when flat.
	Delimiter string      `json:"delimiter"`
	Role      MailboxRole `json:"role"`
	// Messages stored locally for this mailbox.
	Total int64 `json:"total"`
	// Unread messages stored locally for this mailbox.
	Unread int64 `json:"unread"`
	// A Gmail label: a message can be in several labels at once, moving it out of
	// one removes only that label, and All Mail is where Archive moves to.
	Label bool `json:"label"`
}

Mailbox: One mailbox of one account.

type MailboxChanged

type MailboxChanged struct {
	ID        int64 `json:"id"`
	AccountID int64 `json:"accountId"`
	Deleted   bool  `json:"deleted"`
}

MailboxChanged: A mailbox was created, renamed, deleted, or its counts changed.

func (MailboxChanged) Durable

func (MailboxChanged) Durable() bool

Durable reports whether MailboxChanged is kept in the changes log.

func (MailboxChanged) EventName

func (MailboxChanged) EventName() string

EventName is the wire name of MailboxChanged.

type MailboxCheck

type MailboxCheck struct {
	MailboxID int64  `json:"mailboxId"`
	Path      string `json:"path"`
	// Messages on the server.
	Server int64 `json:"server"`
	// Messages stored locally.
	Local int64 `json:"local"`
	// Server UIDs with no local message (at most 20). UIDs from the folder's last
	// UIDNEXT on are new mail, not missing.
	MissingLocally []int64 `json:"missingLocally"`
	// Local UIDs the server no longer has (at most 20).
	MissingOnServer []int64 `json:"missingOnServer"`
	// Messages whose flags differ, leaving out those changed since the last pass
	// or waiting for a queued action.
	FlagDiffs int64 `json:"flagDiffs"`
	// Gmail: messages whose labels differ, with the same exceptions.
	LabelDiffs int64 `json:"labelDiffs"`
}

MailboxCheck: How one synced folder compares with the server.

type MailboxClient

type MailboxClient struct {
	// contains filtered or unexported fields
}

MailboxClient calls the mailbox methods; it implements MailboxService.

func (MailboxClient) Create

Create calls mailbox.create.

func (MailboxClient) Delete

Delete calls mailbox.delete.

func (MailboxClient) Erase

Erase calls mailbox.erase.

func (MailboxClient) List

List calls mailbox.list.

func (MailboxClient) Move

Move calls mailbox.move.

func (MailboxClient) Rename

Rename calls mailbox.rename.

func (MailboxClient) SetRole

SetRole calls mailbox.setRole.

type MailboxCreateParams

type MailboxCreateParams struct {
	AccountID int64 `json:"accountId"`
	// 1-100 characters, without the account's hierarchy delimiter.
	Name string `json:"name"`
	// A mailbox of the same account.
	ParentID *int64 `json:"parentId,omitzero"`
}

MailboxCreateParams holds the params of mailbox.create.

type MailboxDeleteParams

type MailboxDeleteParams struct {
	ID int64 `json:"id"`
}

MailboxDeleteParams holds the params of mailbox.delete.

type MailboxEraseParams

type MailboxEraseParams struct {
	ID int64 `json:"id"`
}

MailboxEraseParams holds the params of mailbox.erase.

type MailboxListParams

type MailboxListParams struct {
	// Limit to one account. Omit for all accounts.
	AccountID *int64 `json:"accountId,omitzero"`
}

MailboxListParams holds the params of mailbox.list.

type MailboxMoveParams

type MailboxMoveParams struct {
	ID       int64  `json:"id"`
	ParentID *int64 `json:"parentId,omitzero"`
}

MailboxMoveParams holds the params of mailbox.move.

type MailboxRenameParams

type MailboxRenameParams struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

MailboxRenameParams holds the params of mailbox.rename.

type MailboxRole

type MailboxRole string

MailboxRole: What a mailbox is for, from SPECIAL-USE attributes or name heuristics.

const (
	// An ordinary user folder.
	MailboxRoleNone    MailboxRole = "none"
	MailboxRoleInbox   MailboxRole = "inbox"
	MailboxRoleDrafts  MailboxRole = "drafts"
	MailboxRoleSent    MailboxRole = "sent"
	MailboxRoleArchive MailboxRole = "archive"
	MailboxRoleJunk    MailboxRole = "junk"
	MailboxRoleTrash   MailboxRole = "trash"
	// All messages (Gmail All Mail).
	MailboxRoleAll MailboxRole = "all"
	// A server-side flagged view (Gmail Starred).
	MailboxRoleFlagged MailboxRole = "flagged"
)

func (MailboxRole) Valid

func (v MailboxRole) Valid() bool

Valid reports whether v is one of the declared values.

type MailboxService

type MailboxService interface {
	// List implements mailbox.list. Mailboxes ordered by account, role, then
	// path.
	List(ctx context.Context, p *MailboxListParams) ([]Mailbox, error)
	// Create implements mailbox.create. Make a mailbox (a label on Gmail), at the
	// top level or inside parentId, at once here and on the server when online.
	// Conflict when the name is taken or the account is read-only.
	Create(ctx context.Context, p *MailboxCreateParams) (*Mailbox, error)
	// Rename implements mailbox.rename. Give a mailbox a new name in the same
	// place; the mailboxes inside it follow. Conflict for a mailbox with a role,
	// while the account has changes waiting to reach the server, or when the name
	// is taken.
	Rename(ctx context.Context, p *MailboxRenameParams) (*Mailbox, error)
	// Move implements mailbox.move. Put a mailbox inside parentId, or at the top
	// level without it; the mailboxes inside it follow. Conflict as rename, and
	// for a parent inside the mailbox itself.
	Move(ctx context.Context, p *MailboxMoveParams) (*Mailbox, error)
	// Delete implements mailbox.delete. Delete a mailbox, the mailboxes inside
	// it, and their messages (on Gmail, the labels; the messages stay in All
	// Mail). Conflict as rename.
	Delete(ctx context.Context, p *MailboxDeleteParams) error
	// SetRole implements mailbox.setRole. Use This Mailbox For: make a mailbox
	// the account's drafts, sent, junk, trash or archive mailbox, in place of the
	// one the server names. Conflict on Gmail, whose mailboxes keep their roles.
	SetRole(ctx context.Context, p *MailboxSetRoleParams) (*Mailbox, error)
	// Erase implements mailbox.erase. Erase Deleted Items or Erase Junk Mail:
	// delete every message in a trash or junk mailbox for good. Returns how many.
	Erase(ctx context.Context, p *MailboxEraseParams) (int64, error)
}

MailboxService: Mailboxes (IMAP folders, and Gmail labels shown as folders).

type MailboxSetRoleParams

type MailboxSetRoleParams struct {
	ID int64 `json:"id"`
	// drafts, sent, junk, trash or archive.
	Role MailboxRole `json:"role"`
}

MailboxSetRoleParams holds the params of mailbox.setRole.

type Message

type Message struct {
	Summary MessageSummary `json:"summary"`
	To      []Address      `json:"to"`
	Cc      []Address      `json:"cc"`
	ReplyTo []Address      `json:"replyTo"`
	// Message-ID without angle brackets.
	MessageID       string   `json:"messageId"`
	InReplyTo       string   `json:"inReplyTo"`
	References      []string `json:"references"`
	ListID          string   `json:"listId"`
	ListUnsubscribe string   `json:"listUnsubscribe"`
	Parts           []Part   `json:"parts"`
	// Whether the full message is stored locally.
	BodyFetched bool `json:"bodyFetched"`
}

Message: Everything about a message except its body.

type MessageAnnounced

type MessageAnnounced struct {
	AccountID int64          `json:"accountId"`
	Notes     []Announcement `json:"notes"`
}

MessageAnnounced: New mail and fired Remind Me reminders to announce, sent live to every connected client when maild has no desktop to notify on (no session bus, as behind lodge, docs/specs/lodge-app.md); each client shows the notes itself. Never replayed.

func (MessageAnnounced) Durable

func (MessageAnnounced) Durable() bool

Durable reports whether MessageAnnounced is kept in the changes log.

func (MessageAnnounced) EventName

func (MessageAnnounced) EventName() string

EventName is the wire name of MessageAnnounced.

type MessageBodyParams

type MessageBodyParams struct {
	ID int64 `json:"id"`
}

MessageBodyParams holds the params of message.body.

type MessageByMessageIDParams

type MessageByMessageIDParams struct {
	// The Message-ID, with or without its angle brackets.
	MessageID string `json:"messageId"`
}

MessageByMessageIDParams holds the params of message.byMessageId.

type MessageChanged

type MessageChanged struct {
	AccountID int64   `json:"accountId"`
	IDs       []int64 `json:"ids"`
}

MessageChanged: Messages were added or changed (flags, mailbox, fetched body).

func (MessageChanged) Durable

func (MessageChanged) Durable() bool

Durable reports whether MessageChanged is kept in the changes log.

func (MessageChanged) EventName

func (MessageChanged) EventName() string

EventName is the wire name of MessageChanged.

type MessageClient

type MessageClient struct {
	// contains filtered or unexported fields
}

MessageClient calls the message methods; it implements MessageService.

func (MessageClient) Body

Body calls message.body.

func (MessageClient) ByMessageID

ByMessageID calls message.byMessageId.

func (MessageClient) Copy

Copy calls message.copy.

func (MessageClient) Delete

Delete calls message.delete.

func (MessageClient) Get

Get calls message.get.

func (MessageClient) Move

Move calls message.move.

func (MessageClient) Mute

Mute calls message.mute.

func (MessageClient) Part

Part calls message.part.

func (MessageClient) Redirect

Redirect calls message.redirect.

func (MessageClient) Remind

Remind calls message.remind.

func (MessageClient) Render

Render calls message.render.

func (MessageClient) Save

Save calls message.save.

func (MessageClient) SetFlags

SetFlags calls message.setFlags.

func (MessageClient) Source

Source calls message.source.

func (MessageClient) Summaries

Summaries calls message.summaries.

func (MessageClient) Unsubscribe

Unsubscribe calls message.unsubscribe.

func (MessageClient) UnsubscribeInfo

UnsubscribeInfo calls message.unsubscribeInfo.

type MessageCopyParams

type MessageCopyParams struct {
	IDs       []int64 `json:"ids"`
	MailboxID int64   `json:"mailboxId"`
}

MessageCopyParams holds the params of message.copy.

type MessageDeleteParams

type MessageDeleteParams struct {
	IDs []int64 `json:"ids"`
}

MessageDeleteParams holds the params of message.delete.

type MessageGetParams

type MessageGetParams struct {
	ID int64 `json:"id"`
}

MessageGetParams holds the params of message.get.

type MessageMoveParams

type MessageMoveParams struct {
	IDs       []int64 `json:"ids"`
	MailboxID int64   `json:"mailboxId"`
	// The mailbox the messages leave, where a message can be in several (Gmail
	// labels): moving out of a label removes that label only. Omit for the
	// mailbox that holds them; for Gmail that is INBOX when they are in it.
	FromMailboxID *int64 `json:"fromMailboxId,omitzero"`
}

MessageMoveParams holds the params of message.move.

type MessageMuteParams

type MessageMuteParams struct {
	// At least one.
	IDs   []int64 `json:"ids"`
	Muted bool    `json:"muted"`
}

MessageMuteParams holds the params of message.mute.

type MessagePartParams

type MessagePartParams struct {
	ID int64 `json:"id"`
	// The part's IMAP specifier from Message.parts.
	Path string `json:"path"`
}

MessagePartParams holds the params of message.part.

type MessageRedirectParams

type MessageRedirectParams struct {
	ID int64 `json:"id"`
	// At least one.
	To []Address `json:"to"`
}

MessageRedirectParams holds the params of message.redirect.

type MessageRemindParams

type MessageRemindParams struct {
	IDs []int64 `json:"ids"`
	// In the future.
	At *time.Time `json:"at,omitzero"`
}

MessageRemindParams holds the params of message.remind.

type MessageRemoved

type MessageRemoved struct {
	AccountID int64   `json:"accountId"`
	IDs       []int64 `json:"ids"`
}

MessageRemoved: Messages no longer exist locally.

func (MessageRemoved) Durable

func (MessageRemoved) Durable() bool

Durable reports whether MessageRemoved is kept in the changes log.

func (MessageRemoved) EventName

func (MessageRemoved) EventName() string

EventName is the wire name of MessageRemoved.

type MessageRenderParams

type MessageRenderParams struct {
	ID     int64 `json:"id"`
	Remote *bool `json:"remote,omitzero"`
	// Also keep the reader's page for maild's lodge content route, and name it in
	// contentPath.
	Content *bool `json:"content,omitzero"`
}

MessageRenderParams holds the params of message.render.

type MessageSaveParams

type MessageSaveParams struct {
	ID int64 `json:"id"`
	// An absolute path the user chose.
	Path string `json:"path"`
}

MessageSaveParams holds the params of message.save.

type MessageService

type MessageService interface {
	// Get implements message.get. One message's headers and structure.
	Get(ctx context.Context, p *MessageGetParams) (*Message, error)
	// Body implements message.body. A message's text, fetching the message from
	// the server first if it is not stored locally.
	Body(ctx context.Context, p *MessageBodyParams) (*Body, error)
	// Summaries implements message.summaries. Summaries of messages in the order
	// given; IDs that no longer exist are skipped.
	Summaries(ctx context.Context, p *MessageSummariesParams) ([]MessageSummary, error)
	// ByMessageID implements message.byMessageId. The message a Message-ID names,
	// for lodge's permanent route /message/<Message-ID>
	// (docs/specs/lodge-app.md): among the stored messages with that Message-ID,
	// one in an inbox, else one in neither Trash nor Junk, else any; the earliest
	// stored of those. notFound when none is.
	ByMessageID(ctx context.Context, p *MessageByMessageIDParams) (*MessageSummary, error)
	// Render implements message.render. A message prepared for the reader,
	// fetching it first if it is not stored locally. Remote images are loaded
	// through maild only when remote is true; tracking images never are.
	Render(ctx context.Context, p *MessageRenderParams) (*Rendering, error)
	// Part implements message.part. Decode one part (an attachment or inline
	// image) into the parts cache.
	Part(ctx context.Context, p *MessagePartParams) (*PartFile, error)
	// SetFlags implements message.setFlags. Change flags locally at once and on
	// the server when it can be reached.
	SetFlags(ctx context.Context, p *MessageSetFlagsParams) error
	// Move implements message.move. Move messages to another mailbox of the same
	// account.
	Move(ctx context.Context, p *MessageMoveParams) error
	// Copy implements message.copy. Copy messages to another mailbox of their
	// account. On Gmail the copy is the destination label, added at once; only
	// labels can be copied into. Elsewhere the server makes a new message, which
	// appears in the destination once the server has it (on the next replay while
	// online). Messages already in the destination are skipped.
	Copy(ctx context.Context, p *MessageCopyParams) error
	// Delete implements message.delete. Move messages to the account's Trash;
	// messages already in Trash are deleted from the server.
	Delete(ctx context.Context, p *MessageDeleteParams) error
	// Source implements message.source. Raw Source and All Headers: the message
	// as the server holds it, fetched first when it is not stored. Bytes that are
	// not UTF-8 show as U+FFFD. With content, also the message's path on maild's
	// lodge content route, for Save As by download.
	Source(ctx context.Context, p *MessageSourceParams) (*MessageSource, error)
	// Save implements message.save. Save As: write the message as the server
	// holds it (an .eml file) to path, replacing a file there. invalidParams for
	// a relative path.
	Save(ctx context.Context, p *MessageSaveParams) error
	// UnsubscribeInfo implements message.unsubscribeInfo. How a list message can
	// be left, from its stored headers (the body is fetched first when it is not
	// stored).
	UnsubscribeInfo(ctx context.Context, p *MessageUnsubscribeInfoParams) (*Unsubscribe, error)
	// Unsubscribe implements message.unsubscribe. Unsubscribe by one of the
	// message's methods, after the user confirmed: oneclick sends the POST
	// (unavailable with why when it fails), mail queues the message from the
	// account's address, web returns the page to open. The list is remembered.
	// invalidParams for a method the message does not offer; conflict for a
	// read-only account.
	Unsubscribe(ctx context.Context, p *MessageUnsubscribeParams) (*UnsubscribeResult, error)
	// Redirect implements message.redirect. Redirect: send the message as it is
	// to other people, with Resent-From, Resent-To, Resent-Date and
	// Resent-Message-ID added, from the account's address, through the outbox
	// (the undo delay applies). Conflict for a read-only account.
	Redirect(ctx context.Context, p *MessageRedirectParams) (*OutboxItem, error)
	// Mute implements message.mute. Mute or unmute the conversations of messages
	// (ADR-0028): a muted conversation's new mail never notifies. Emits
	// message.changed for every message of the conversations.
	Mute(ctx context.Context, p *MessageMuteParams) error
	// Remind implements message.remind. Remind Me: at a time, bring messages back
	// to the top of their account's inbox and notify (ADR-0025). Without at,
	// clear their reminders. Conflict for a read-only account's messages.
	Remind(ctx context.Context, p *MessageRemindParams) error
}

MessageService: Messages. An ID is local and stays the same while the message exists, including across moves the server reports with COPYUID.

type MessageSetFlagsParams

type MessageSetFlagsParams struct {
	IDs     []int64     `json:"ids"`
	Changes FlagChanges `json:"changes"`
}

MessageSetFlagsParams holds the params of message.setFlags.

type MessageSource

type MessageSource struct {
	// The header section, up to the blank line.
	Headers string `json:"headers"`
	// The whole message, at most 2 MB of it.
	Text string `json:"text"`
	// The message is longer than text.
	Truncated bool `json:"truncated"`
	// With source's content, on a maild serving lodge: the whole message on
	// maild's content route, as m/<mac>/<blob>/<name>.eml, which downloads with
	// ?download=1 (docs/specs/lodge-app.md).
	ContentPath *string `json:"contentPath,omitzero"`
}

MessageSource: A message as the server holds it.

type MessageSourceParams

type MessageSourceParams struct {
	ID int64 `json:"id"`
	// Also name the whole message on maild's lodge content route, in contentPath.
	Content *bool `json:"content,omitzero"`
}

MessageSourceParams holds the params of message.source.

type MessageSummariesParams

type MessageSummariesParams struct {
	IDs []int64 `json:"ids"`
}

MessageSummariesParams holds the params of message.summaries.

type MessageSummary

type MessageSummary struct {
	ID        int64 `json:"id"`
	AccountID int64 `json:"accountId"`
	// Mailboxes holding the message: one for IMAP, one per label for Gmail.
	MailboxIDs []int64 `json:"mailboxIds"`
	ThreadID   int64   `json:"threadId"`
	Subject    string  `json:"subject"`
	From       Address `json:"from"`
	// The Date header, or the server's arrival time when Date is missing or
	// invalid.
	Date time.Time `json:"date"`
	// The first lines of the text, without quotes or signature.
	Preview        string `json:"preview"`
	Flags          Flags  `json:"flags"`
	HasAttachments bool   `json:"hasAttachments"`
	// Size in bytes on the server.
	Size int64 `json:"size"`
	// Messages in the thread across every mailbox; 1 for a message alone.
	ThreadCount int64 `json:"threadCount"`
	// When a pending Remind Me reminder brings the message back.
	RemindAt *time.Time `json:"remindAt,omitzero"`
	// Present and true when the message's conversation is muted (ADR-0028).
	Muted *bool `json:"muted,omitzero"`
}

MessageSummary: A row of a message list.

type MessageUnsubscribeInfoParams

type MessageUnsubscribeInfoParams struct {
	ID int64 `json:"id"`
}

MessageUnsubscribeInfoParams holds the params of message.unsubscribeInfo.

type MessageUnsubscribeParams

type MessageUnsubscribeParams struct {
	ID     int64             `json:"id"`
	Method UnsubscribeMethod `json:"method"`
}

MessageUnsubscribeParams holds the params of message.unsubscribe.

type NoticeKind

type NoticeKind string

NoticeKind: What a change tells invitees, through the calendar's server (ADR-0035).

const (
	// A new event with invitees, invitees added, or a deleted event restored.
	NoticeKindInvitations NoticeKind = "invitations"
	// Something invitees see changed: title, location, notes, times, recurrence
	// or status.
	NoticeKindUpdates NoticeKind = "updates"
	// The event, an occurrence or the rest of a series deleted, or invitees
	// removed.
	NoticeKindCancellations NoticeKind = "cancellations"
)

func (NoticeKind) Valid

func (v NoticeKind) Valid() bool

Valid reports whether v is one of the declared values.

type NotifyScope

type NotifyScope string

NotifyScope: Which new mail notifies, after each account's own notify switch.

const (
	// New mail in an inbox (the default).
	NotifyScopeInbox NotifyScope = "inbox"
	// New mail in an inbox from a VIP.
	NotifyScopeVips NotifyScope = "vips"
	// New mail in an inbox from an address in People.
	NotifyScopeContacts NotifyScope = "contacts"
	// New mail in any mailbox but Junk, Trash and Sent.
	NotifyScopeAll NotifyScope = "all"
	// New mail that a smart mailbox lists (notifySmartId).
	NotifyScopeSmart NotifyScope = "smart"
)

func (NotifyScope) Valid

func (v NotifyScope) Valid() bool

Valid reports whether v is one of the declared values.

type OAuthClient

type OAuthClient struct {
	Provider OAuthProvider `json:"provider"`
	ClientID string        `json:"clientId"`
	// A client secret is stored.
	HasSecret bool `json:"hasSecret"`
}

OAuthClient: A registered OAuth client.

type OAuthProvider

type OAuthProvider string

OAuthProvider: An OAuth identity provider maild knows the endpoints of.

const (
	// Google accounts (Gmail).
	OAuthProviderGoogle OAuthProvider = "google"
	// Microsoft accounts (Outlook.com, Hotmail); maild has a built-in client,
	// which setClient replaces.
	OAuthProviderMicrosoft OAuthProvider = "microsoft"
)

func (OAuthProvider) Valid

func (v OAuthProvider) Valid() bool

Valid reports whether v is one of the declared values.

type OauthClient

type OauthClient struct {
	// contains filtered or unexported fields
}

OauthClient calls the oauth methods; it implements OauthService.

func (OauthClient) GetClient

GetClient calls oauth.getClient.

func (OauthClient) SetClient

SetClient calls oauth.setClient.

type OauthGetClientParams

type OauthGetClientParams struct {
	Provider OAuthProvider `json:"provider"`
}

OauthGetClientParams holds the params of oauth.getClient.

type OauthService

type OauthService interface {
	// SetClient implements oauth.setClient. Store the client maild signs in to a
	// provider with, replacing any previous one.
	SetClient(ctx context.Context, p *OauthSetClientParams) (*OAuthClient, error)
	// GetClient implements oauth.getClient. The client stored for a provider.
	GetClient(ctx context.Context, p *OauthGetClientParams) (*OAuthClient, error)
}

OauthService: The OAuth clients maild signs in with. Microsoft's is built in (ADR-0039); for Google, until Frostmail ships a verified client (M6), the user registers their own (docs/design/accounts.md). The client secret is write-only.

type OauthSetClientParams

type OauthSetClientParams struct {
	Provider OAuthProvider `json:"provider"`
	ClientID string        `json:"clientId"`
	// Desktop clients have one; it is kept in the secret store.
	ClientSecret *string `json:"clientSecret,omitzero"`
}

OauthSetClientParams holds the params of oauth.setClient.

type Occurrence

type Occurrence struct {
	// The single event, the series' master, or the override that replaced this
	// occurrence.
	EventID int64 `json:"eventId"`
	// Which occurrence of a series: its original start as stored; empty for a
	// single event.
	RecurrenceID string `json:"recurrenceId"`
	CalendarID   int64  `json:"calendarId"`
	AccountID    int64  `json:"accountId"`
	Summary      string `json:"summary"`
	Location     string `json:"location"`
	AllDay       bool   `json:"allDay"`
	// Timed: the start. All-day: midnight of startDate in the range's time zone.
	Start time.Time `json:"start"`
	// Exclusive.
	End time.Time `json:"end"`
	// All-day: the first day, YYYY-MM-DD. Empty for timed events.
	StartDate string `json:"startDate"`
	// All-day: the day after the last. Empty for timed events.
	EndDate string      `json:"endDate"`
	Status  EventStatus `json:"status"`
	// The user's answer, when invited.
	Answer *PartStat `json:"answer,omitzero"`
	// Does not count as busy.
	Transparent bool `json:"transparent"`
	// Part of a series.
	Recurring bool `json:"recurring"`
}

Occurrence: One occurrence of an event.

type OutboxCancelParams

type OutboxCancelParams struct {
	ID int64 `json:"id"`
}

OutboxCancelParams holds the params of outbox.cancel.

type OutboxChanged

type OutboxChanged struct {
	ID        int64       `json:"id"`
	AccountID int64       `json:"accountId"`
	State     OutboxState `json:"state"`
	// The message left the outbox unsent: cancelled, or replaced by a new send of
	// its draft.
	Deleted bool `json:"deleted"`
}

OutboxChanged: An outbox message changed state.

func (OutboxChanged) Durable

func (OutboxChanged) Durable() bool

Durable reports whether OutboxChanged is kept in the changes log.

func (OutboxChanged) EventName

func (OutboxChanged) EventName() string

EventName is the wire name of OutboxChanged.

type OutboxClient

type OutboxClient struct {
	// contains filtered or unexported fields
}

OutboxClient calls the outbox methods; it implements OutboxService.

func (OutboxClient) Cancel

func (x OutboxClient) Cancel(ctx context.Context, p *OutboxCancelParams) (*Draft, error)

Cancel calls outbox.cancel.

func (OutboxClient) List

List calls outbox.list.

func (OutboxClient) Reschedule

Reschedule calls outbox.reschedule.

func (OutboxClient) Retry

Retry calls outbox.retry.

type OutboxItem

type OutboxItem struct {
	ID        int64 `json:"id"`
	AccountID int64 `json:"accountId"`
	// Set until the message is accepted.
	DraftID *int64      `json:"draftId,omitzero"`
	Subject string      `json:"subject"`
	To      []Address   `json:"to"`
	State   OutboxState `json:"state"`
	// When a queued message goes out.
	SendAt *time.Time `json:"sendAt,omitzero"`
	// Send Later: queued for a chosen time rather than in its undo window.
	Scheduled bool  `json:"scheduled"`
	Attempts  int64 `json:"attempts"`
	// The last error, when there was one.
	Error *string `json:"error,omitzero"`
}

OutboxItem: One message on its way out.

type OutboxListParams

type OutboxListParams struct {
	AccountID *int64 `json:"accountId,omitzero"`
}

OutboxListParams holds the params of outbox.list.

type OutboxRescheduleParams

type OutboxRescheduleParams struct {
	ID     int64     `json:"id"`
	SendAt time.Time `json:"sendAt"`
}

OutboxRescheduleParams holds the params of outbox.reschedule.

type OutboxRetryParams

type OutboxRetryParams struct {
	ID int64 `json:"id"`
}

OutboxRetryParams holds the params of outbox.retry.

type OutboxService

type OutboxService interface {
	// List implements outbox.list. Messages not yet sent, oldest first.
	List(ctx context.Context, p *OutboxListParams) ([]OutboxItem, error)
	// Cancel implements outbox.cancel. Stop a queued message (undo send) and
	// return its draft; a draft with id 0 for a message maild wrote itself, such
	// as an invitation's answer.
	Cancel(ctx context.Context, p *OutboxCancelParams) (*Draft, error)
	// Retry implements outbox.retry. Queue a failed message again, now.
	Retry(ctx context.Context, p *OutboxRetryParams) error
	// Reschedule implements outbox.reschedule. Give a scheduled message a new
	// time and rebuild it with that time as its Date; a time within the undo
	// delay sends it after the undo delay. Conflict unless the message is queued
	// and scheduled.
	Reschedule(ctx context.Context, p *OutboxRescheduleParams) (*OutboxItem, error)
}

OutboxService: Messages on their way out (docs/design/send.md, Outbox).

type OutboxState

type OutboxState string

OutboxState: Where a message is on its way out.

const (
	// Waiting for its send time: the undo delay, or a retry after an error.
	OutboxStateQueued OutboxState = "queued"
	// Being handed to the SMTP server.
	OutboxStateSending OutboxState = "sending"
	// The SMTP server took it; the Sent copy is being saved.
	OutboxStateAccepted OutboxState = "accepted"
	// Done.
	OutboxStateSent OutboxState = "sent"
	// The server refused it; the draft is kept.
	OutboxStateFailed OutboxState = "failed"
)

func (OutboxState) Valid

func (v OutboxState) Valid() bool

Valid reports whether v is one of the declared values.

type Part

type Part struct {
	// IMAP part specifier, such as 1 or 1.2.
	Path string `json:"path"`
	// Lowercase type/subtype.
	ContentType string `json:"contentType"`
	Filename    string `json:"filename"`
	// inline, attachment or empty.
	Disposition string `json:"disposition"`
	// Without angle brackets.
	ContentID string `json:"contentId"`
	// Encoded size in bytes.
	Size int64 `json:"size"`
}

Part: One MIME part.

type PartFile

type PartFile struct {
	// Relative to the parts cache, as in a mailpart://localhost/ URL.
	Path string `json:"path"`
	// Lowercase type/subtype.
	ContentType string `json:"contentType"`
	// A safe file name: the part's, or one made from its type.
	Filename string `json:"filename"`
	// Decoded size in bytes.
	Size int64 `json:"size"`
	// On a maild serving lodge: the part on maild's content route, as
	// p/<mac>/<path> (docs/specs/lodge-app.md).
	ContentPath *string `json:"contentPath,omitzero"`
}

PartFile: A message part decoded into the parts cache.

type PartStat

type PartStat string

PartStat: An attendee's answer to an invitation (iCalendar PARTSTAT).

const (
	// Not answered.
	PartStatNeedsaction PartStat = "needsaction"
	PartStatAccepted    PartStat = "accepted"
	PartStatDeclined    PartStat = "declined"
	// Maybe.
	PartStatTentative PartStat = "tentative"
	PartStatDelegated PartStat = "delegated"
)

func (PartStat) Valid

func (v PartStat) Valid() bool

Valid reports whether v is one of the declared values.

type PeopleAddParams

type PeopleAddParams struct {
	Email string `json:"email"`
	// Default: the name last seen with the address in mail.
	Name *string `json:"name,omitzero"`
	// Default: the default address book of the first account with contacts on.
	CollectionID *int64 `json:"collectionId,omitzero"`
}

PeopleAddParams holds the params of people.add.

type PeopleCardParams

type PeopleCardParams struct {
	Email string `json:"email"`
}

PeopleCardParams holds the params of people.card.

type PeopleChanged

type PeopleChanged struct {
	AccountID int64 `json:"accountId"`
}

PeopleChanged: An account's contacts changed, so people may have.

func (PeopleChanged) Durable

func (PeopleChanged) Durable() bool

Durable reports whether PeopleChanged is kept in the changes log.

func (PeopleChanged) EventName

func (PeopleChanged) EventName() string

EventName is the wire name of PeopleChanged.

type PeopleClient

type PeopleClient struct {
	// contains filtered or unexported fields
}

PeopleClient calls the people methods; it implements PeopleService.

func (PeopleClient) Add

Add calls people.add.

func (PeopleClient) Card

Card calls people.card.

func (PeopleClient) Create

Create calls people.create.

func (PeopleClient) Delete

Delete calls people.delete.

func (PeopleClient) Get

Get calls people.get.

func (PeopleClient) List

List calls people.list.

func (PeopleClient) Photo

Photo calls people.photo.

func (PeopleClient) Restore

Restore calls people.restore.

func (PeopleClient) Senders

Senders calls people.senders.

func (PeopleClient) SetPhoto

SetPhoto calls people.setPhoto.

func (PeopleClient) Update

Update calls people.update.

type PeopleCreateParams

type PeopleCreateParams struct {
	// Default: the default address book of the first account with contacts on.
	CollectionID *int64 `json:"collectionId,omitzero"`
	// At least a name, an organization or an email address.
	Fields ContactFields `json:"fields"`
}

PeopleCreateParams holds the params of people.create.

type PeopleDeleteParams

type PeopleDeleteParams struct {
	ID int64 `json:"id"`
}

PeopleDeleteParams holds the params of people.delete.

type PeopleGetParams

type PeopleGetParams struct {
	ID int64 `json:"id"`
}

PeopleGetParams holds the params of people.get.

type PeopleListParams

type PeopleListParams struct {
	Query *string `json:"query,omitzero"`
	// Only people with a contact in this address book.
	CollectionID *int64 `json:"collectionId,omitzero"`
}

PeopleListParams holds the params of people.list.

type PeoplePhotoParams

type PeoplePhotoParams struct {
	ID int64 `json:"id"`
}

PeoplePhotoParams holds the params of people.photo.

type PeopleRefused

type PeopleRefused struct {
	AccountID int64 `json:"accountId"`
	// Absent when the contact is gone.
	ContactID *int64 `json:"contactId,omitzero"`
	Name      string `json:"name"`
	// changed (another client changed the same fields), deleted, or refused.
	Reason string `json:"reason"`
}

PeopleRefused: The server refused a change and it could not be applied again; the server's version stands (ADR-0030).

func (PeopleRefused) Durable

func (PeopleRefused) Durable() bool

Durable reports whether PeopleRefused is kept in the changes log.

func (PeopleRefused) EventName

func (PeopleRefused) EventName() string

EventName is the wire name of PeopleRefused.

type PeopleRestoreParams

type PeopleRestoreParams struct {
	RestoreID string `json:"restoreId"`
}

PeopleRestoreParams holds the params of people.restore.

type PeopleSendersParams

type PeopleSendersParams struct {
	// At most 500.
	Addresses []string `json:"addresses"`
}

PeopleSendersParams holds the params of people.senders.

type PeopleService

type PeopleService interface {
	// List implements people.list. People sorted by name. With query, those whose
	// name, organization or email address has a word starting with it,
	// case-insensitively.
	List(ctx context.Context, p *PeopleListParams) ([]PersonSummary, error)
	// Get implements people.get. One person with their contacts.
	Get(ctx context.Context, p *PeopleGetParams) (*Person, error)
	// Card implements people.card. The contact card for an email address, person
	// or not.
	Card(ctx context.Context, p *PeopleCardParams) (*ContactCard, error)
	// Photo implements people.photo. A person's photo, from the first of their
	// contacts that has one.
	Photo(ctx context.Context, p *PeoplePhotoParams) (*Photo, error)
	// Senders implements people.senders. Which of these addresses belong to a
	// person with a photo, for contact photos in the message list. Addresses
	// without one are left out.
	Senders(ctx context.Context, p *PeopleSendersParams) ([]SenderPhoto, error)
	// Add implements people.add. Add to Contacts: store a new vCard 3.0 with the
	// name and address in an address book and write it to the server.
	Add(ctx context.Context, p *PeopleAddParams) (*Person, error)
	// Create implements people.create. Add a contact (a vCard 3.0) to an address
	// book and write it to the server (ADR-0030).
	Create(ctx context.Context, p *PeopleCreateParams) (*ContactWrite, error)
	// Update implements people.update. Change a contact; the vCard keeps
	// everything the fields do not touch (ADR-0030).
	Update(ctx context.Context, p *PeopleUpdateParams) (*ContactWrite, error)
	// Delete implements people.delete. Delete a contact from its address book and
	// the server.
	Delete(ctx context.Context, p *PeopleDeleteParams) (*ContactWrite, error)
	// SetPhoto implements people.setPhoto. Set or remove a contact's photo; the
	// app scales it to at most 512 by 512 first.
	SetPhoto(ctx context.Context, p *PeopleSetPhotoParams) (*ContactWrite, error)
	// Restore implements people.restore. Undo a create, update, delete or
	// setPhoto by writing back what it replaced (ADR-0032).
	Restore(ctx context.Context, p *PeopleRestoreParams) error
}

PeopleService: Contacts from the accounts' address books, joined into people by email address across address books and accounts (docs/design/pim.md), and their edits (ADR-0030, ADR-0032).

type PeopleSetPhotoParams

type PeopleSetPhotoParams struct {
	ID int64 `json:"id"`
	// JPEG or PNG, at most 256 KB; absent removes the photo.
	Photo *Photo `json:"photo,omitzero"`
}

PeopleSetPhotoParams holds the params of people.setPhoto.

type PeopleUpdateParams

type PeopleUpdateParams struct {
	// The contact's ID.
	ID     int64         `json:"id"`
	Fields ContactFields `json:"fields"`
}

PeopleUpdateParams holds the params of people.update.

type Person

type Person struct {
	ID           int64  `json:"id"`
	DisplayName  string `json:"displayName"`
	Organization string `json:"organization"`
	HasPhoto     bool   `json:"hasPhoto"`
	// In address book order: by account, then collection position.
	Contacts []Contact `json:"contacts"`
}

Person: A person and every contact that makes them up.

type PersonSummary

type PersonSummary struct {
	ID           int64  `json:"id"`
	DisplayName  string `json:"displayName"`
	Organization string `json:"organization"`
	// The first email address of the person's first contact, or empty.
	Email    string `json:"email"`
	HasPhoto bool   `json:"hasPhoto"`
	// The letter the person files under in the list: the sort key's first letter,
	// uppercased, or # when it is not a letter.
	Index string `json:"index"`
}

PersonSummary: A row of the People list.

type Photo

type Photo struct {
	// Such as image/jpeg.
	ContentType string `json:"contentType"`
	// The image, base64-encoded.
	Data string `json:"data"`
}

Photo: A person's photo.

type PostalAddress

type PostalAddress struct {
	// home, work, other, or the card's own label; may be empty.
	Label string `json:"label"`
	// The street lines, joined by newlines.
	Street   string `json:"street"`
	Locality string `json:"locality"`
	Region   string `json:"region"`
	Postcode string `json:"postcode"`
	Country  string `json:"country"`
}

PostalAddress: A postal address from a vCard's ADR.

type RPCClient

type RPCClient struct {
	// contains filtered or unexported fields
}

RPCClient calls the rpc methods; it implements RPCService.

func (RPCClient) Hello

func (x RPCClient) Hello(ctx context.Context, p *RPCHelloParams) (*Hello, error)

Hello calls rpc.hello.

func (RPCClient) Ping

func (x RPCClient) Ping(ctx context.Context, p *RPCPingParams) error

Ping calls rpc.ping.

type RPCHelloParams

type RPCHelloParams struct {
	// Protocol major version the client speaks.
	Protocol int64 `json:"protocol"`
	// Client name and version, for logs.
	Client string `json:"client"`
}

RPCHelloParams holds the params of rpc.hello.

type RPCPingParams

type RPCPingParams struct{}

RPCPingParams holds the params of rpc.ping.

type RPCService

type RPCService interface {
	// Hello implements rpc.hello. Negotiate the protocol major version. Changes
	// within a major version are additive only.
	Hello(ctx context.Context, p *RPCHelloParams) (*Hello, error)
	// Ping implements rpc.ping. Do nothing; a web client calls it at least every
	// 30 s while visible, so lodge keeps its session.
	Ping(ctx context.Context, p *RPCPingParams) error
}

RPCService: Connection setup. A client calls rpc.hello first on every connection; the server answers any other method with notReady until hello succeeds.

type Reminder

type Reminder struct {
	// Opaque; names the occurrence and alarm for calendar.snooze and
	// calendar.dismiss.
	ID           string    `json:"id"`
	EventID      int64     `json:"eventId"`
	RecurrenceID string    `json:"recurrenceId"`
	CalendarID   int64     `json:"calendarId"`
	Summary      string    `json:"summary"`
	Location     string    `json:"location"`
	AllDay       bool      `json:"allDay"`
	Start        time.Time `json:"start"`
	StartDate    string    `json:"startDate"`
	// When the alarm went off, or the snooze ended.
	DueAt time.Time `json:"dueAt"`
}

Reminder: An alarm that is due.

type Rendering

type Rendering struct {
	// Sanitized HTML for the sandboxed reader frame, or empty for a text-only
	// message. Parts and loaded remote images are mailpart://localhost/ URLs.
	HTML string `json:"html"`
	// The readable text, as message.body returns it.
	Text string `json:"text"`
	// Remote resources left out: not requested, or requested and failed.
	Remote int64 `json:"remote"`
	// Tracking images removed; they are never loaded.
	Trackers int64 `json:"trackers"`
	// With render's content, on a maild serving lodge: the reader's whole page on
	// maild's content route, as r/<token>.html (docs/specs/lodge-app.md). Absent
	// for a message without HTML.
	ContentPath *string `json:"contentPath,omitzero"`
}

Rendering: A message prepared for the reader.

type Router

type Router struct {
	*jsonrpc.Router[CallerKind, ErrorCode]
}

Router maps wire method names to service implementations. Unknown methods, methods the request's caller (CallerFrom) may not use, and for an agent methods its scope does not grant (MethodNeed), return ErrMethodNotFound alike.

func NewRouter

func NewRouter(s Services) (*Router, error)

NewRouter registers every service; a nil service is an error.

type Rule

type Rule struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
	// Rules run in position order, from 0.
	Position   int64      `json:"position"`
	Enabled    bool       `json:"enabled"`
	Conditions Conditions `json:"conditions"`
	// Run in order: flags and read marks, then copies, then the move or delete.
	Actions []RuleAction `json:"actions"`
	// Why an action cannot run, such as a mailbox that is gone.
	Problem *string `json:"problem,omitzero"`
}

Rule: One rule.

type RuleAction

type RuleAction struct {
	Kind RuleActionKind `json:"kind"`
	// For move and copy.
	MailboxID *int64 `json:"mailboxId,omitzero"`
	// For flag: 1-7.
	Color *int64 `json:"color,omitzero"`
}

RuleAction: One action.

type RuleActionKind

type RuleActionKind string

RuleActionKind: What a rule does to a message that meets its conditions.

const (
	// Move to mailboxId (messages of that mailbox's account only).
	RuleActionKindMove RuleActionKind = "move"
	// Copy to mailboxId (messages of that mailbox's account only).
	RuleActionKindCopy RuleActionKind = "copy"
	// Mark as read.
	RuleActionKindRead RuleActionKind = "read"
	// Flag with color (1-7).
	RuleActionKindFlag RuleActionKind = "flag"
	// Move to Trash, as message.delete.
	RuleActionKindDelete RuleActionKind = "delete"
	// Notify, whatever the notification scope.
	RuleActionKindNotify RuleActionKind = "notify"
	// Stop evaluating rules for this message.
	RuleActionKindStop RuleActionKind = "stop"
)

func (RuleActionKind) Valid

func (v RuleActionKind) Valid() bool

Valid reports whether v is one of the declared values.

type RuleApplied

type RuleApplied struct {
	// Messages that met at least one rule's conditions.
	Matched int64 `json:"matched"`
}

RuleApplied: What apply did.

type RuleApplyParams

type RuleApplyParams struct {
	IDs []int64 `json:"ids"`
}

RuleApplyParams holds the params of rule.apply.

type RuleChanged

type RuleChanged struct {
	ID      int64 `json:"id"`
	Deleted bool  `json:"deleted"`
}

RuleChanged: A rule was created, changed, moved or deleted.

func (RuleChanged) Durable

func (RuleChanged) Durable() bool

Durable reports whether RuleChanged is kept in the changes log.

func (RuleChanged) EventName

func (RuleChanged) EventName() string

EventName is the wire name of RuleChanged.

type RuleClient

type RuleClient struct {
	// contains filtered or unexported fields
}

RuleClient calls the rule methods; it implements RuleService.

func (RuleClient) Apply

Apply calls rule.apply.

func (RuleClient) Create

func (x RuleClient) Create(ctx context.Context, p *RuleCreateParams) (*Rule, error)

Create calls rule.create.

func (RuleClient) Delete

func (x RuleClient) Delete(ctx context.Context, p *RuleDeleteParams) error

Delete calls rule.delete.

func (RuleClient) List

func (x RuleClient) List(ctx context.Context, p *RuleListParams) ([]Rule, error)

List calls rule.list.

func (RuleClient) Move

func (x RuleClient) Move(ctx context.Context, p *RuleMoveParams) error

Move calls rule.move.

func (RuleClient) Update

func (x RuleClient) Update(ctx context.Context, p *RuleUpdateParams) (*Rule, error)

Update calls rule.update.

type RuleCreateParams

type RuleCreateParams struct {
	Name       string       `json:"name"`
	Conditions Conditions   `json:"conditions"`
	Actions    []RuleAction `json:"actions"`
	// Default true.
	Enabled *bool `json:"enabled,omitzero"`
}

RuleCreateParams holds the params of rule.create.

type RuleDeleteParams

type RuleDeleteParams struct {
	ID int64 `json:"id"`
}

RuleDeleteParams holds the params of rule.delete.

type RuleListParams

type RuleListParams struct{}

RuleListParams holds the params of rule.list.

type RuleMoveParams

type RuleMoveParams struct {
	ID       int64 `json:"id"`
	Position int64 `json:"position"`
}

RuleMoveParams holds the params of rule.move.

type RuleService

type RuleService interface {
	// List implements rule.list. Every rule, in order.
	List(ctx context.Context, p *RuleListParams) ([]Rule, error)
	// Create implements rule.create. Add a rule at the end of the list.
	Create(ctx context.Context, p *RuleCreateParams) (*Rule, error)
	// Update implements rule.update. Change the fields given.
	Update(ctx context.Context, p *RuleUpdateParams) (*Rule, error)
	// Delete implements rule.delete. Remove a rule.
	Delete(ctx context.Context, p *RuleDeleteParams) error
	// Move implements rule.move. Put a rule at a position, moving the others
	// along.
	Move(ctx context.Context, p *RuleMoveParams) error
	// Apply implements rule.apply. Run the enabled rules, in order, on these
	// messages now; conflict when one is in a read-only account.
	Apply(ctx context.Context, p *RuleApplyParams) (*RuleApplied, error)
}

RuleService: Rules that act on new inbox mail in maild, before it notifies, and on chosen messages with apply (ADR-0024, docs/design/organize.md).

type RuleUpdateParams

type RuleUpdateParams struct {
	ID         int64        `json:"id"`
	Name       *string      `json:"name,omitzero"`
	Conditions *Conditions  `json:"conditions,omitzero"`
	Actions    []RuleAction `json:"actions,omitzero"`
	Enabled    *bool        `json:"enabled,omitzero"`
}

RuleUpdateParams holds the params of rule.update.

type Scope

type Scope struct {
	// All is account=*: every account, those added later included.
	All bool
	// Accounts are the account IDs of account=<id>[,<id>…], ascending.
	Accounts []int64
	// Write is ;write: flags, moves and drafts.
	Write bool
	// Send is ;send: queueing a draft to send.
	Send bool
}

Scope is what an agent's MCP token lets it reach (docs/specs/lodge-app.md, /mcp): every account, or the accounts named, to read, and with ;write and ;send to change and to send. Lodge passes it in Lodge-Scope without reading it; maild's router admits the methods it covers (schema/rpc's scope), and the engine the accounts it names, on the agent's connection.

func ParseScope

func ParseScope(s string) (Scope, error)

ParseScope parses account=* or account=<id>[,<id>…], IDs being positive decimal integers without leading zeros, then optionally ;write and then ;send, each at most once.

func (Scope) Admits

func (s Scope) Admits(id int64) bool

Admits reports whether the scope reaches account id.

func (Scope) Grants

func (s Scope) Grants(n ScopeNeed) bool

Grants reports whether the scope covers what a method needs.

func (Scope) String

func (s Scope) String() string

String is the scope in ParseScope's grammar.

type ScopeNeed

type ScopeNeed string

ScopeNeed is what a method needs of an agent's scope beyond reading (schema/rpc's scope).

const (
	NeedRead  ScopeNeed = ""
	NeedWrite ScopeNeed = "write"
	NeedSend  ScopeNeed = "send"
)

What methods need.

func MethodNeed

func MethodNeed(method string) ScopeNeed

MethodNeed is what method needs of an agent's scope.

type SenderPhoto

type SenderPhoto struct {
	// Lowercased.
	Address  string `json:"address"`
	PersonID int64  `json:"personId"`
}

SenderPhoto: An address whose person has a photo (people.photo).

type ServerConfig

type ServerConfig struct {
	Host string  `json:"host"`
	Port int64   `json:"port"`
	TLS  TLSMode `json:"tls"`
	// Login name; often the email address.
	Username string `json:"username"`
}

ServerConfig: Where and how to reach one server.

type ServiceKind

type ServiceKind string

ServiceKind: A service an account syncs besides mail (ADR-0017).

const (
	// Address books over CardDAV.
	ServiceKindContacts ServiceKind = "contacts"
	// Calendars over CalDAV.
	ServiceKindCalendar ServiceKind = "calendar"
	// Google Tasks for Google accounts; task lists over CalDAV for others.
	ServiceKindTasks ServiceKind = "tasks"
)

func (ServiceKind) Valid

func (v ServiceKind) Valid() bool

Valid reports whether v is one of the declared values.

type ServiceSettings

type ServiceSettings struct {
	Service ServiceKind `json:"service"`
	// The provider offers the service; iCloud's tasks, for one, are out of reach.
	Available bool `json:"available"`
	Enabled   bool `json:"enabled"`
	// Where the service lives: the DAV home set, or the Tasks API. Empty until
	// found.
	URL string `json:"url"`
	// The account's sign-in covers the service. False for a Google account whose
	// grant lacks the service's scope: account.authorize asks for it.
	SignedIn bool `json:"signedIn"`
	// The end of the last complete pass.
	LastSyncAt *time.Time `json:"lastSyncAt,omitzero"`
	// Why the last pass failed.
	Error *string `json:"error,omitzero"`
	// Why the service is not available, for the user to read; absent when it is,
	// or when no reason is known.
	Reason *string `json:"reason,omitzero"`
}

ServiceSettings: One of an account's services besides mail.

type Services

type Services struct {
	Account  AccountService
	Address  AddressService
	Block    BlockService
	Calendar CalendarService
	Draft    DraftService
	Events   EventsService
	Identity IdentityService
	Mailbox  MailboxService
	Message  MessageService
	Oauth    OauthService
	Outbox   OutboxService
	People   PeopleService
	RPC      RPCService
	Rule     RuleService
	Settings SettingsService
	Smart    SmartService
	Sync     SyncService
	Tasks    TasksService
	Thread   ThreadService
	View     ViewService
	Vip      VipService
}

Services is one implementation per domain, for NewRouter.

type Settings

type Settings struct {
	// Seconds a sent message waits in the outbox: 0, 10, 20 or 30.
	UndoDelay   int64       `json:"undoDelay"`
	NotifyScope NotifyScope `json:"notifyScope"`
	// The smart mailbox, when notifyScope is smart.
	NotifySmartID *int64 `json:"notifySmartId,omitzero"`
	// Seven names, for flag colors 1-7; an empty name is the color's own (Red ...
	// Gray).
	FlagNames []string `json:"flagNames"`
	// Mailboxes added to the sidebar's Favorites, in order; mailboxes since
	// deleted are left out. Absent when there are none.
	Favorites []int64 `json:"favorites,omitzero"`
	// mark when absent.
	BlockAction *BlockAction `json:"blockAction,omitzero"`
}

Settings: Every preference, with its current value.

type SettingsChanged

type SettingsChanged struct{}

SettingsChanged: A preference changed.

func (SettingsChanged) Durable

func (SettingsChanged) Durable() bool

Durable reports whether SettingsChanged is kept in the changes log.

func (SettingsChanged) EventName

func (SettingsChanged) EventName() string

EventName is the wire name of SettingsChanged.

type SettingsClient

type SettingsClient struct {
	// contains filtered or unexported fields
}

SettingsClient calls the settings methods; it implements SettingsService.

func (SettingsClient) Get

Get calls settings.get.

func (SettingsClient) Set

Set calls settings.set.

type SettingsGetParams

type SettingsGetParams struct{}

SettingsGetParams holds the params of settings.get.

type SettingsService

type SettingsService interface {
	// Get implements settings.get. The current preferences.
	Get(ctx context.Context, p *SettingsGetParams) (*Settings, error)
	// Set implements settings.set. Change the preferences given; the others stay.
	// Returns them all.
	Set(ctx context.Context, p *SettingsSetParams) (*Settings, error)
}

SettingsService: Preferences maild keeps for every account, so they hold with the app closed and look the same from mailctl (ADR-0026, docs/design/organize.md).

type SettingsSetParams

type SettingsSetParams struct {
	// 0, 10, 20 or 30.
	UndoDelay   *int64       `json:"undoDelay,omitzero"`
	NotifyScope *NotifyScope `json:"notifyScope,omitzero"`
	// Required with notifyScope smart.
	NotifySmartID *int64 `json:"notifySmartId,omitzero"`
	// Seven names, each at most 40 characters.
	FlagNames []string `json:"flagNames,omitzero"`
	// Mailbox IDs, at most 50, without repeats.
	Favorites   []int64      `json:"favorites,omitzero"`
	BlockAction *BlockAction `json:"blockAction,omitzero"`
}

SettingsSetParams holds the params of settings.set.

type SmartChanged

type SmartChanged struct {
	ID      int64 `json:"id"`
	Deleted bool  `json:"deleted"`
}

SmartChanged: A smart mailbox was created, changed, moved or deleted.

func (SmartChanged) Durable

func (SmartChanged) Durable() bool

Durable reports whether SmartChanged is kept in the changes log.

func (SmartChanged) EventName

func (SmartChanged) EventName() string

EventName is the wire name of SmartChanged.

type SmartClient

type SmartClient struct {
	// contains filtered or unexported fields
}

SmartClient calls the smart methods; it implements SmartService.

func (SmartClient) Create

Create calls smart.create.

func (SmartClient) Delete

Delete calls smart.delete.

func (SmartClient) FromSearch

FromSearch calls smart.fromSearch.

func (SmartClient) List

List calls smart.list.

func (SmartClient) Move

Move calls smart.move.

func (SmartClient) Update

Update calls smart.update.

type SmartCreateParams

type SmartCreateParams struct {
	Name         string     `json:"name"`
	Conditions   Conditions `json:"conditions"`
	IncludeTrash *bool      `json:"includeTrash,omitzero"`
	IncludeSent  *bool      `json:"includeSent,omitzero"`
}

SmartCreateParams holds the params of smart.create.

type SmartDeleteParams

type SmartDeleteParams struct {
	ID int64 `json:"id"`
}

SmartDeleteParams holds the params of smart.delete.

type SmartFromSearchParams

type SmartFromSearchParams struct {
	// The search language (docs/specs/search.md).
	Text string `json:"text"`
	// A search scoped to one mailbox.
	MailboxID *int64 `json:"mailboxId,omitzero"`
}

SmartFromSearchParams holds the params of smart.fromSearch.

type SmartListParams

type SmartListParams struct{}

SmartListParams holds the params of smart.list.

type SmartMailbox

type SmartMailbox struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
	// Its place in the sidebar, from 0.
	Position   int64      `json:"position"`
	Conditions Conditions `json:"conditions"`
	// Also list messages that are only in Trash.
	IncludeTrash bool `json:"includeTrash"`
	// Also list messages that are only in Sent.
	IncludeSent bool `json:"includeSent"`
	// Unread messages it lists.
	Unread int64 `json:"unread"`
}

SmartMailbox: One smart mailbox.

type SmartMoveParams

type SmartMoveParams struct {
	ID       int64 `json:"id"`
	Position int64 `json:"position"`
}

SmartMoveParams holds the params of smart.move.

type SmartService

type SmartService interface {
	// List implements smart.list. Every smart mailbox, in sidebar order.
	List(ctx context.Context, p *SmartListParams) ([]SmartMailbox, error)
	// Create implements smart.create. Add a smart mailbox at the end of the list.
	Create(ctx context.Context, p *SmartCreateParams) (*SmartMailbox, error)
	// Update implements smart.update. Change the fields given.
	Update(ctx context.Context, p *SmartUpdateParams) (*SmartMailbox, error)
	// FromSearch implements smart.fromSearch. The conditions that list what a
	// search lists, for Save as Smart Mailbox; save them with includeTrash and
	// includeSent, as a search looks everywhere.
	FromSearch(ctx context.Context, p *SmartFromSearchParams) (*Conditions, error)
	// Delete implements smart.delete. Remove a smart mailbox; a notification
	// scope that named it becomes inbox.
	Delete(ctx context.Context, p *SmartDeleteParams) error
	// Move implements smart.move. Put a smart mailbox at a position, moving the
	// others along.
	Move(ctx context.Context, p *SmartMoveParams) error
}

SmartService: Smart mailboxes: saved conditions listed as a mailbox, across accounts (ADR-0023, docs/design/organize.md).

type SmartUpdateParams

type SmartUpdateParams struct {
	ID           int64       `json:"id"`
	Name         *string     `json:"name,omitzero"`
	Conditions   *Conditions `json:"conditions,omitzero"`
	IncludeTrash *bool       `json:"includeTrash,omitzero"`
	IncludeSent  *bool       `json:"includeSent,omitzero"`
}

SmartUpdateParams holds the params of smart.update.

type Subscription

type Subscription struct {
	// The latest durable sequence number when the subscription started.
	Seq int64 `json:"seq"`
	// True when sinceSeq is older than the retained log; the client must refetch
	// all state.
	Resync bool `json:"resync"`
}

Subscription: The state of a new subscription.

type SyncClient

type SyncClient struct {
	// contains filtered or unexported fields
}

SyncClient calls the sync methods; it implements SyncService.

func (SyncClient) Now

func (x SyncClient) Now(ctx context.Context, p *SyncNowParams) error

Now calls sync.now.

func (SyncClient) Pim

func (x SyncClient) Pim(ctx context.Context, p *SyncPimParams) error

Pim calls sync.pim.

func (SyncClient) Status

func (x SyncClient) Status(ctx context.Context, p *SyncStatusParams) ([]SyncStatus, error)

Status calls sync.status.

type SyncNowParams

type SyncNowParams struct {
	AccountID int64 `json:"accountId"`
}

SyncNowParams holds the params of sync.now.

type SyncPhase

type SyncPhase string

SyncPhase: What an account's sync is doing.

const (
	// Up to date and watching for changes.
	SyncPhaseIdle SyncPhase = "idle"
	// Connecting and logging in.
	SyncPhaseConnecting SyncPhase = "connecting"
	// Listing mailboxes.
	SyncPhaseListing SyncPhase = "listing"
	// Reconciling mailboxes with the server.
	SyncPhaseSyncing SyncPhase = "syncing"
	// The server cannot be reached; retrying with backoff.
	SyncPhaseOffline SyncPhase = "offline"
	// The server rejected the credentials; account.setPassword retries.
	SyncPhaseUnauthorized SyncPhase = "unauthorized"
	// An unexpected error stopped sync; the error field says why. Retried with
	// backoff.
	SyncPhaseFailed SyncPhase = "failed"
)

func (SyncPhase) Valid

func (v SyncPhase) Valid() bool

Valid reports whether v is one of the declared values.

type SyncPimParams

type SyncPimParams struct {
	// Default: every account.
	AccountID *int64 `json:"accountId,omitzero"`
}

SyncPimParams holds the params of sync.pim.

type SyncProgress

type SyncProgress struct {
	Status SyncStatus `json:"status"`
}

SyncProgress: An account's sync state changed.

func (SyncProgress) Durable

func (SyncProgress) Durable() bool

Durable reports whether SyncProgress is kept in the changes log.

func (SyncProgress) EventName

func (SyncProgress) EventName() string

EventName is the wire name of SyncProgress.

type SyncService

type SyncService interface {
	// Status implements sync.status. The sync state of every account, or of one.
	Status(ctx context.Context, p *SyncStatusParams) ([]SyncStatus, error)
	// Now implements sync.now. Reconcile every mailbox of the account now instead
	// of at the next poll.
	Now(ctx context.Context, p *SyncNowParams) error
	// Pim implements sync.pim. Poll the contacts, calendar and tasks services now
	// instead of at the next 5-minute pass. The app calls it when its window
	// gains focus; maild skips accounts polled in the last minute.
	Pim(ctx context.Context, p *SyncPimParams) error
}

SyncService: Account synchronization state and control.

type SyncStatus

type SyncStatus struct {
	AccountID int64     `json:"accountId"`
	Phase     SyncPhase `json:"phase"`
	// The mailbox path being synced, while syncing.
	Mailbox *string `json:"mailbox,omitzero"`
	// Progress within the phase; 0 with total 0 when unknown.
	Done  int64   `json:"done"`
	Total int64   `json:"total"`
	Error *string `json:"error,omitzero"`
	// When every mailbox was last reconciled.
	LastSyncAt *time.Time `json:"lastSyncAt,omitzero"`
}

SyncStatus: One account's sync state.

type SyncStatusParams

type SyncStatusParams struct {
	AccountID *int64 `json:"accountId,omitzero"`
}

SyncStatusParams holds the params of sync.status.

type TLSMode

type TLSMode string

TLSMode: How a connection is secured.

const (
	// TLS from the first byte (IMAPS 993, SMTPS 465).
	TLSModeTLS TLSMode = "tls"
	// Plain connection upgraded with STARTTLS (143, 587).
	TLSModeStartTLS TLSMode = "starttls"
	// No TLS. Only for local test servers.
	TLSModeInsecure TLSMode = "insecure"
)

func (TLSMode) Valid

func (v TLSMode) Valid() bool

Valid reports whether v is one of the declared values.

type Task

type Task struct {
	ID int64 `json:"id"`
	// Its collection.
	ListID    int64 `json:"listId"`
	AccountID int64 `json:"accountId"`
	// The task this one is a subtask of.
	ParentID *int64 `json:"parentId,omitzero"`
	Title    string `json:"title"`
	Notes    string `json:"notes"`
	// YYYY-MM-DD, or empty. Google keeps only the date; a CalDAV due time is kept
	// in the source and not shown.
	Due         string     `json:"due"`
	Completed   bool       `json:"completed"`
	CompletedAt *time.Time `json:"completedAt,omitzero"`
	// The stored message a task made from mail in Gmail links to.
	MessageID *int64 `json:"messageId,omitzero"`
	ReadOnly  bool   `json:"readOnly"`
}

Task: A task.

type TasksChanged

type TasksChanged struct {
	AccountID int64 `json:"accountId"`
}

TasksChanged: An account's task lists or tasks changed.

func (TasksChanged) Durable

func (TasksChanged) Durable() bool

Durable reports whether TasksChanged is kept in the changes log.

func (TasksChanged) EventName

func (TasksChanged) EventName() string

EventName is the wire name of TasksChanged.

type TasksClient

type TasksClient struct {
	// contains filtered or unexported fields
}

TasksClient calls the tasks methods; it implements TasksService.

func (TasksClient) Create

func (x TasksClient) Create(ctx context.Context, p *TasksCreateParams) (*Task, error)

Create calls tasks.create.

func (TasksClient) Delete

Delete calls tasks.delete.

func (TasksClient) Get

func (x TasksClient) Get(ctx context.Context, p *TasksGetParams) (*Task, error)

Get calls tasks.get.

func (TasksClient) List

func (x TasksClient) List(ctx context.Context, p *TasksListParams) ([]Task, error)

List calls tasks.list.

func (TasksClient) Update

func (x TasksClient) Update(ctx context.Context, p *TasksUpdateParams) (*Task, error)

Update calls tasks.update.

type TasksCreateParams

type TasksCreateParams struct {
	// Default: the default list of the first account with tasks on.
	ListID *int64  `json:"listId,omitzero"`
	Title  string  `json:"title"`
	Notes  *string `json:"notes,omitzero"`
	// YYYY-MM-DD.
	Due      *string `json:"due,omitzero"`
	ParentID *int64  `json:"parentId,omitzero"`
}

TasksCreateParams holds the params of tasks.create.

type TasksDeleteParams

type TasksDeleteParams struct {
	ID int64 `json:"id"`
}

TasksDeleteParams holds the params of tasks.delete.

type TasksGetParams

type TasksGetParams struct {
	ID int64 `json:"id"`
}

TasksGetParams holds the params of tasks.get.

type TasksListParams

type TasksListParams struct {
	// Only this list.
	ListID *int64 `json:"listId,omitzero"`
	// Include completed tasks. Default false.
	Completed *bool `json:"completed,omitzero"`
	// Only tasks due before this day, YYYY-MM-DD, as the To-Do bar asks.
	DueBefore *string `json:"dueBefore,omitzero"`
}

TasksListParams holds the params of tasks.list.

type TasksService

type TasksService interface {
	// List implements tasks.list. Tasks of enabled lists of accounts with the
	// tasks service on, list by list in collection order; within a list, by the
	// server's position, each parent followed by its subtasks.
	List(ctx context.Context, p *TasksListParams) ([]Task, error)
	// Get implements tasks.get. One task.
	Get(ctx context.Context, p *TasksGetParams) (*Task, error)
	// Create implements tasks.create. Add a task at the top of its list, and
	// write it to the server.
	Create(ctx context.Context, p *TasksCreateParams) (*Task, error)
	// Update implements tasks.update. Change a task; omitted fields keep their
	// values.
	Update(ctx context.Context, p *TasksUpdateParams) (*Task, error)
	// Delete implements tasks.delete. Delete a task and its subtasks.
	Delete(ctx context.Context, p *TasksDeleteParams) error
}

TasksService: Tasks from Google Tasks and from CalDAV task lists (docs/design/pim.md). Flagged mail, which the Tasks module and the To-Do bar show beside them, comes from view.open with flagged set.

type TasksUpdateParams

type TasksUpdateParams struct {
	ID    int64   `json:"id"`
	Title *string `json:"title,omitzero"`
	Notes *string `json:"notes,omitzero"`
	// YYYY-MM-DD, or empty to clear.
	Due       *string `json:"due,omitzero"`
	Completed *bool   `json:"completed,omitzero"`
}

TasksUpdateParams holds the params of tasks.update.

type ThreadAwaitingOthersParams

type ThreadAwaitingOthersParams struct {
	// 1 to 25; default 10.
	Limit *int64 `json:"limit,omitzero"`
	// At least this many days old, 0 to 30; default 5.
	WaitingDays *int64 `json:"waitingDays,omitzero"`
	// Less than this many days old, 1 to 90; default 30.
	WithinDays *int64 `json:"withinDays,omitzero"`
}

ThreadAwaitingOthersParams holds the params of thread.awaitingOthers.

type ThreadAwaitingReplyParams

type ThreadAwaitingReplyParams struct {
	// 1 to 25; default 5.
	Limit *int64 `json:"limit,omitzero"`
	// At least this many days old, 0 to 30; default 0.
	WaitingDays *int64 `json:"waitingDays,omitzero"`
	// Less than this many days old, 1 to 90; default 30.
	WithinDays *int64 `json:"withinDays,omitzero"`
}

ThreadAwaitingReplyParams holds the params of thread.awaitingReply.

type ThreadClient

type ThreadClient struct {
	// contains filtered or unexported fields
}

ThreadClient calls the thread methods; it implements ThreadService.

func (ThreadClient) AwaitingOthers

func (x ThreadClient) AwaitingOthers(ctx context.Context, p *ThreadAwaitingOthersParams) (*Awaiting, error)

AwaitingOthers calls thread.awaitingOthers.

func (ThreadClient) AwaitingReply

func (x ThreadClient) AwaitingReply(ctx context.Context, p *ThreadAwaitingReplyParams) (*Awaiting, error)

AwaitingReply calls thread.awaitingReply.

func (ThreadClient) Messages

Messages calls thread.messages.

type ThreadMessagesParams

type ThreadMessagesParams struct {
	ID int64 `json:"id"`
}

ThreadMessagesParams holds the params of thread.messages.

type ThreadService

type ThreadService interface {
	// Messages implements thread.messages. The messages of a thread in every
	// mailbox, oldest first, without messages deleted locally.
	Messages(ctx context.Context, p *ThreadMessagesParams) ([]MessageSummary, error)
	// AwaitingReply implements thread.awaitingReply. Conversations waiting on the
	// user (docs/specs/lodge-app.md, Calendar, tasks and contacts): those whose
	// newest message, leaving out drafts and messages only in Drafts, Trash or
	// Junk, is from someone else to one of its account's identities in To, from
	// no list or no-reply sender, not answered, muted or blocked, in an inbox,
	// and dated between withinDays and waitingDays ago.
	AwaitingReply(ctx context.Context, p *ThreadAwaitingReplyParams) (*Awaiting, error)
	// AwaitingOthers implements thread.awaitingOthers. Conversations waiting on
	// other people: those whose newest message, chosen as for awaitingReply, is
	// from one of its account's identities to someone who is none of any
	// account's identities, not muted, and dated between withinDays and
	// waitingDays ago.
	AwaitingOthers(ctx context.Context, p *ThreadAwaitingOthersParams) (*Awaiting, error)
}

ThreadService: Conversations, built by maild from message references (Gmail threads on Gmail).

type Unsubscribe

type Unsubscribe struct {
	// Best first; empty for a message from no list.
	Methods []UnsubscribeMethod `json:"methods"`
	// The list's name: List-Id's phrase, else its ID, else the sender's name or
	// address.
	List string `json:"list"`
	// Where oneclick's request goes.
	Host *string `json:"host,omitzero"`
	// Where mail goes.
	Address *string `json:"address,omitzero"`
	// The page web opens.
	URL *string `json:"url,omitzero"`
	// The user unsubscribed from this list (or from this message) before.
	Done bool `json:"done"`
}

Unsubscribe: How a list message can be left, and whether it was.

type UnsubscribeMethod

type UnsubscribeMethod string

UnsubscribeMethod: How a list message can be left (ADR-0027), best first.

const (
	// An HTTPS POST that maild sends (RFC 8058), for a sender the provider's DKIM
	// vouches for.
	UnsubscribeMethodOneclick UnsubscribeMethod = "oneclick"
	// A message to the list's mailto: address, through the outbox.
	UnsubscribeMethodMail UnsubscribeMethod = "mail"
	// The list's https: page, which the app opens in the browser.
	UnsubscribeMethodWeb UnsubscribeMethod = "web"
)

func (UnsubscribeMethod) Valid

func (v UnsubscribeMethod) Valid() bool

Valid reports whether v is one of the declared values.

type UnsubscribeResult

type UnsubscribeResult struct {
	// For web: the page for the app to open.
	URL *string `json:"url,omitzero"`
}

UnsubscribeResult: What unsubscribe did.

type VerifyReport

type VerifyReport struct {
	AccountID int64 `json:"accountId"`
	// No folder or collection differs.
	Ok        bool           `json:"ok"`
	Mailboxes []MailboxCheck `json:"mailboxes"`
	// The enabled collections of the services that are on.
	Collections []CollectionCheck `json:"collections"`
	CheckedAt   time.Time         `json:"checkedAt"`
}

VerifyReport: The result of account.verify.

type ViewClient

type ViewClient struct {
	// contains filtered or unexported fields
}

ViewClient calls the view methods; it implements ViewService.

func (ViewClient) Close

func (x ViewClient) Close(ctx context.Context, p *ViewCloseParams) error

Close calls view.close.

func (ViewClient) Count

func (x ViewClient) Count(ctx context.Context, p *ViewCountParams) ([]ViewCount, error)

Count calls view.count.

func (ViewClient) Open

func (x ViewClient) Open(ctx context.Context, p *ViewOpenParams) (*ViewInfo, error)

Open calls view.open.

func (ViewClient) Range

Range calls view.range.

type ViewCloseParams

type ViewCloseParams struct {
	ID int64 `json:"id"`
}

ViewCloseParams holds the params of view.close.

type ViewCount

type ViewCount struct {
	Total  int64 `json:"total"`
	Unread int64 `json:"unread"`
}

ViewCount: How many messages a query lists.

type ViewCountParams

type ViewCountParams struct {
	// At most 100.
	Queries []ViewQuery `json:"queries"`
}

ViewCountParams holds the params of view.count.

type ViewDelta

type ViewDelta struct {
	ID int64 `json:"id"`
	// The row count after the ops.
	Count int64    `json:"count"`
	Ops   []ViewOp `json:"ops"`
}

ViewDelta: A view's rows changed. Rows a client holds are moved by the ops; fetch inserted rows with view.range.

func (ViewDelta) Durable

func (ViewDelta) Durable() bool

Durable reports whether ViewDelta is kept in the changes log.

func (ViewDelta) EventName

func (ViewDelta) EventName() string

EventName is the wire name of ViewDelta.

type ViewInfo

type ViewInfo struct {
	ID    int64 `json:"id"`
	Count int64 `json:"count"`
}

ViewInfo: An open view.

type ViewOp

type ViewOp struct {
	Op    ViewOpKind `json:"op"`
	At    int64      `json:"at"`
	Count int64      `json:"count"`
}

ViewOp: One step of a delta; apply a delta's ops in order.

type ViewOpKind

type ViewOpKind string

ViewOpKind: How a delta changes a view.

const (
	// count rows were inserted at index at.
	ViewOpKindInsert ViewOpKind = "insert"
	// count rows starting at index at were removed.
	ViewOpKindRemove ViewOpKind = "remove"
)

func (ViewOpKind) Valid

func (v ViewOpKind) Valid() bool

Valid reports whether v is one of the declared values.

type ViewOpenParams

type ViewOpenParams struct {
	Query ViewQuery `json:"query"`
}

ViewOpenParams holds the params of view.open.

type ViewQuery

type ViewQuery struct {
	AccountID *int64 `json:"accountId,omitzero"`
	MailboxID *int64 `json:"mailboxId,omitzero"`
	// Full-text search terms.
	Text *string `json:"text,omitzero"`
	// true: unread only; false: read only. A row that stops matching only because
	// it was read or unread while the view is open stays until the view is
	// reopened, so a message read in an Unread list does not vanish under the
	// pointer.
	Unread *bool `json:"unread,omitzero"`
	// true: flagged only; false: unflagged only. Unlike unread, a row whose flag
	// changes leaves at once: flagging is deliberate, and the Tasks module's
	// Flagged Mail completes a message by unflagging it.
	Flagged *bool `json:"flagged,omitzero"`
	// true: only messages with attachments; false: only those without.
	HasAttachments *bool `json:"hasAttachments,omitzero"`
	// Messages in mailboxes with this role in any account, such as every inbox.
	Role *MailboxRole `json:"role,omitzero"`
	// One row per thread: its newest message that matches.
	Threads *bool `json:"threads,omitzero"`
	// Conditions every listed message also meets.
	Conditions *Conditions `json:"conditions,omitzero"`
	// The messages of a smart mailbox, which the view follows as it is edited.
	SmartMailboxID *int64 `json:"smartMailboxId,omitzero"`
	// More conditions, which must also hold: the filter bar's, beside a source's
	// own.
	Filter *Conditions `json:"filter,omitzero"`
	// The order; date by default. With threads, threads are ordered by their
	// row's message.
	Sort *ViewSort `json:"sort,omitzero"`
	// Lowest first: oldest, A to Z, smallest, and unflagged, read or without
	// attachments before the others. Descending by default.
	Ascending *bool `json:"ascending,omitzero"`
}

ViewQuery: Which messages a view lists, newest first unless sort says otherwise. Every field that is set must match.

type ViewRangeParams

type ViewRangeParams struct {
	ID    int64 `json:"id"`
	Start int64 `json:"start"`
	End   int64 `json:"end"`
}

ViewRangeParams holds the params of view.range.

type ViewService

type ViewService interface {
	// Open implements view.open. Open a view; deltas follow on this connection
	// without events.subscribe.
	Open(ctx context.Context, p *ViewOpenParams) (*ViewInfo, error)
	// Count implements view.count. Count what each query lists, without opening
	// views: the sidebar's Flagged colors, VIPs and other built-in sources.
	// Messages, not threads; a query's threads field is ignored.
	Count(ctx context.Context, p *ViewCountParams) ([]ViewCount, error)
	// Range implements view.range. The rows from start up to, not including, end;
	// end is capped at the view's count.
	Range(ctx context.Context, p *ViewRangeParams) ([]MessageSummary, error)
	// Close implements view.close. Close a view.
	Close(ctx context.Context, p *ViewCloseParams) error
}

ViewService: Live message lists. A view belongs to the connection that opened it, sends its deltas only there, and closes with it.

type ViewSort

type ViewSort string

ViewSort: What a view's rows are ordered by.

const (
	// The list date: arrival, or when a Remind Me reminder fired (the default).
	ViewSortDate ViewSort = "date"
	// The sender's name, else address.
	ViewSortFrom ViewSort = "from"
	// The first recipient's name, else address.
	ViewSortTo ViewSort = "to"
	// The subject without Re: and Fwd:.
	ViewSortSubject ViewSort = "subject"
	ViewSortSize    ViewSort = "size"
	// Flagged, by color.
	ViewSortFlags  ViewSort = "flags"
	ViewSortUnread ViewSort = "unread"
	// Has attachments.
	ViewSortAttachments ViewSort = "attachments"
)

func (ViewSort) Valid

func (v ViewSort) Valid() bool

Valid reports whether v is one of the declared values.

type Vip

type Vip struct {
	// Lowercased.
	Address string `json:"address"`
	// The name to show: the person's in People, else the last one seen, else
	// empty.
	Name string `json:"name"`
	// The person in People with this address, when there is one.
	PersonID *int64 `json:"personId,omitzero"`
}

Vip: One VIP address.

type VipAddParams

type VipAddParams struct {
	Addresses []string `json:"addresses,omitzero"`
	PersonID  *int64   `json:"personId,omitzero"`
}

VipAddParams holds the params of vip.add.

type VipChanged

type VipChanged struct{}

VipChanged: VIPs were added or removed.

func (VipChanged) Durable

func (VipChanged) Durable() bool

Durable reports whether VipChanged is kept in the changes log.

func (VipChanged) EventName

func (VipChanged) EventName() string

EventName is the wire name of VipChanged.

type VipClient

type VipClient struct {
	// contains filtered or unexported fields
}

VipClient calls the vip methods; it implements VipService.

func (VipClient) Add

func (x VipClient) Add(ctx context.Context, p *VipAddParams) ([]Vip, error)

Add calls vip.add.

func (VipClient) List

func (x VipClient) List(ctx context.Context, p *VipListParams) ([]Vip, error)

List calls vip.list.

func (VipClient) Remove

func (x VipClient) Remove(ctx context.Context, p *VipRemoveParams) error

Remove calls vip.remove.

type VipListParams

type VipListParams struct{}

VipListParams holds the params of vip.list.

type VipRemoveParams

type VipRemoveParams struct {
	Addresses []string `json:"addresses,omitzero"`
	PersonID  *int64   `json:"personId,omitzero"`
}

VipRemoveParams holds the params of vip.remove.

type VipService

type VipService interface {
	// List implements vip.list. Every VIP, by name, then address.
	List(ctx context.Context, p *VipListParams) ([]Vip, error)
	// Add implements vip.add. Make addresses VIPs, or every address of a person.
	// Addresses already VIPs stay as they are.
	Add(ctx context.Context, p *VipAddParams) ([]Vip, error)
	// Remove implements vip.remove. Stop addresses being VIPs, or every address
	// of a person.
	Remove(ctx context.Context, p *VipRemoveParams) error
}

VipService: VIP senders: addresses whose mail gets a star, a mailbox of its own, and can be the only mail that notifies (docs/design/organize.md).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL