Documentation
¶
Overview ¶
Package engine implements the maild API domains over the store; the sync engine joins it in M1 (docs/design/overview.md).
Index ¶
- Constants
- func ReminderID(key store.AlarmKey) string
- type Content
- type Deps
- type Engine
- func (e *Engine) Accounts() api.AccountService
- func (e *Engine) Addresses() api.AddressService
- func (e *Engine) Blocks() api.BlockService
- func (e *Engine) Calendar() api.CalendarService
- func (e *Engine) Drafts() api.DraftService
- func (e *Engine) Identities() api.IdentityService
- func (e *Engine) Mailboxes() api.MailboxService
- func (e *Engine) Messages() api.MessageService
- func (e *Engine) Oauth() api.OauthService
- func (e *Engine) Outbox() api.OutboxService
- func (e *Engine) People() api.PeopleService
- func (e *Engine) Rules() api.RuleService
- func (e *Engine) Settings() api.SettingsService
- func (e *Engine) Smart() api.SmartService
- func (e *Engine) Sync() api.SyncService
- func (e *Engine) Tasks() api.TasksService
- func (e *Engine) Threads() api.ThreadService
- func (e *Engine) Views() api.ViewService
- func (e *Engine) Vips() api.VipService
- type PIMSyncer
- type Syncer
- type Unsubscriber
Constants ¶
const AttachmentLimit = 25_000_000
AttachmentLimit is the most attachment data a draft may carry when the SMTP server's own limit is not known.
const ( // MaxUploadChunk is the most one chunk carries, decoded: its base64 // stays well within a 16 MiB message. MaxUploadChunk = 4 << 20 )
Limits on uploads.
Variables ¶
This section is empty.
Functions ¶
func ReminderID ¶
ReminderID is the calendar.reminders id of a reminder's key, for maild's scheduler to find the reminders it fired.
Types ¶
type Content ¶
type Content interface {
// KeepPage keeps a reader page and returns its content path, or "".
KeepPage(page []byte) string
// PartPath is the content path of a parts cache path.
PartPath(rel string) string
// SourcePath is the content path of a stored message's blob, saved as name.
SourcePath(blobID, name string) string
}
Content is what the engine needs of lodge's content route (lodge.Content).
type Deps ¶
type Deps struct {
DB *store.DB
Secrets secrets.Store
Log *slog.Logger
Sync Syncer
Blobs *blob.Store
Views *view.Manager
Render *render.Renderer
// UndoDelay, when set, overrides the undoDelay setting
// (FROSTMAIL_UNDO_DELAY, tests).
UndoDelay time.Duration
// Discovery is how account.discover reaches the network; zero means
// the real HTTPS and DNS.
Discovery discover.Deps
// OAuth signs accounts in; nil makes account.authorize unavailable.
OAuth *oauth.Manager
// PIM syncs contacts, calendars and tasks; nil turns services on
// without discovering them.
PIM PIMSyncer
// Unsubscriber sends one-click unsubscribe requests (ADR-0027); nil
// makes oneclick unavailable.
Unsubscriber Unsubscriber
// NewUID names the contacts, events and tasks maild creates: their
// UIDs, and the hrefs made from them. Nil makes random UUIDs; replay
// tests give the names a recorded session used.
NewUID func() (string, error)
// Content keeps reader pages and names parts and messages for lodge's content route
// (docs/specs/lodge-app.md); nil when maild serves no lodge socket,
// which leaves contentPath out.
Content Content
// contains filtered or unexported fields
}
Deps are what the engine's domains use. Sync, Views and Render may be nil in tests; their methods then report unavailable.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine owns the domain services.
func (*Engine) Accounts ¶
func (e *Engine) Accounts() api.AccountService
Accounts implements the account domain.
func (*Engine) Addresses ¶
func (e *Engine) Addresses() api.AddressService
Addresses implements the address domain.
func (*Engine) Blocks ¶
func (e *Engine) Blocks() api.BlockService
Blocks implements the block domain (ADR-0028).
func (*Engine) Calendar ¶
func (e *Engine) Calendar() api.CalendarService
Calendar implements the calendar domain.
func (*Engine) Drafts ¶
func (e *Engine) Drafts() api.DraftService
Drafts implements the draft domain.
func (*Engine) Identities ¶
func (e *Engine) Identities() api.IdentityService
Identities implements the identity domain.
func (*Engine) Mailboxes ¶
func (e *Engine) Mailboxes() api.MailboxService
Mailboxes implements the mailbox domain.
func (*Engine) Messages ¶
func (e *Engine) Messages() api.MessageService
Messages implements the message domain.
func (*Engine) Outbox ¶
func (e *Engine) Outbox() api.OutboxService
Outbox implements the outbox domain.
func (*Engine) People ¶
func (e *Engine) People() api.PeopleService
People implements the people domain.
func (*Engine) Settings ¶
func (e *Engine) Settings() api.SettingsService
Settings implements the settings domain.
func (*Engine) Tasks ¶
func (e *Engine) Tasks() api.TasksService
Tasks implements the tasks domain (docs/design/pim.md, Tasks). Changes apply to the store at once and wait in pim_ops for pimsync to write them: tasks.insert, tasks.patch and tasks.delete for Google lists, put and delete for CalDAV ones.
func (*Engine) Threads ¶
func (e *Engine) Threads() api.ThreadService
Threads implements the thread domain.
type PIMSyncer ¶
type PIMSyncer interface {
// Reload starts and stops accounts' loops after a service changed.
Reload(ctx context.Context) error
// Poll asks for a pass of an account (0: every account); without force
// it skips accounts polled within the last minute.
Poll(accountID int64, force bool)
// Kick tells an account's loop that changes are queued.
Kick(accountID int64)
// Discover finds a service's DAV home set from start, signing in as the
// account.
Discover(ctx context.Context, accountID int64, service api.ServiceKind, start string) (string, error)
// Verify compares the account's synced collections with the servers.
Verify(ctx context.Context, accountID int64) ([]api.CollectionCheck, error)
// UseServerDefaultCalendar makes the calendar the server names as the
// user's default the account's default, unless the user chose one.
UseServerDefaultCalendar(ctx context.Context, accountID int64) error
}
PIMSyncer is contacts, calendar and tasks sync as the API sees it (pimsync.Manager).
type Syncer ¶
type Syncer interface {
Reload(ctx context.Context) error
Restart(ctx context.Context, accountID int64) error
Status(accountID int64) []api.SyncStatus
SyncNow(accountID int64) error
FetchBody(ctx context.Context, messageID int64) (string, error)
// FetchDisplay is FetchBody for a reader: the whole body when it is
// stored, else the display copy (ADR-0037).
FetchDisplay(ctx context.Context, messageID int64) (string, error)
SetFlags(ctx context.Context, ids []int64, c store.FlagChange) error
Move(ctx context.Context, ids []int64, from, to int64) error
Copy(ctx context.Context, ids []int64, to int64) error
Delete(ctx context.Context, ids []int64) error
// ApplyRules runs the enabled rules on messages now (rule.apply) and
// returns how many met a rule's conditions.
ApplyRules(ctx context.Context, ids []int64) (int, error)
// Mailbox operations (docs/design/organize.md, Mailboxes).
CreateMailbox(ctx context.Context, accountID int64, name string, parentID *int64) (store.Mailbox, error)
RenameMailbox(ctx context.Context, id int64, name string) (store.Mailbox, error)
MoveMailbox(ctx context.Context, id int64, parentID *int64) (store.Mailbox, error)
DeleteMailbox(ctx context.Context, id int64) error
SetMailboxRole(ctx context.Context, id int64, role api.MailboxRole) (store.Mailbox, error)
EraseMailbox(ctx context.Context, id int64) (int, error)
// Verify compares an account's synced folders with the server.
Verify(ctx context.Context, accountID int64) ([]mailsync.Check, error)
// Kick, OutboxChanged and DraftsChanged wake an account's IMAP actor
// (queued ops), sender (queued mail) and draft saver.
Kick(accountID int64)
OutboxChanged(accountID int64)
DraftsChanged(accountID int64)
}
Syncer is the sync engine as the API sees it (mailsync.Manager).