Documentation
¶
Overview ¶
Package api serves the HTTP API described in api/openapi.yaml.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckModules ¶ added in v0.2.0
CheckModules refuses a build whose modules, or mode (MAILRULES_MODE), the daemon cannot serve: a Webhook route that is not Public, a SignIn or SignOut that does not name one of its module's Public GET routes, a SignOut without SignIn, more than one module with SignIn, and cloud mode with no module that signs people in. The daemon calls it before it serves anything.
func NewHandler ¶
NewHandler returns the daemon's HTTP routes.
Types ¶
type ModelSource ¶
type ModelSource interface {
Live(ctx context.Context, tenantID int64) (router *models.Router, minConfidence float64)
RouterFor(ctx context.Context, tenantID int64, spec string) *models.Router
Composer(ctx context.Context, tenantID int64) (models.Generator, error)
}
ModelSource is how this package reaches the models (settings.Settings implements it): the decision router in force, the router of a rule's own model, and the generative model the composer writes with.
type Options ¶
type Options struct {
Store *store.Store
SecureCookies bool // set when the UI is not served from localhost
// TrustedProxies are the peers whose X-Forwarded-For header is believed when counting
// failed sign-ins (MAILRULES_TRUSTED_PROXIES). Empty: the header is never read.
TrustedProxies []netip.Prefix
Now func() time.Time // nil means time.Now
Hub *events.Hub // the SSE stream's source; nil = a private hub nothing publishes to
Exec *actions.Exec // undo and corrections: the only way this package changes a mailbox
Settings *settings.Settings // the settings the user changes at runtime
Models ModelSource // the models the composer and tester use; nil = Settings
Master []byte // seals account passwords
Metrics *telemetry.Metrics // nil = a private registry
Version string // shown in GET /api/settings
// StartCheck starts a cleanup check of an account in the background and returns it,
// running (worker.Manager.StartCheck). Checks holds the account checks in memory, and
// SortAll applies finished checks' kept rows, one undoable batch per mailbox, all started
// or none (worker.Manager.SortAll).
StartCheck func(c worker.Cleanup, fingerprint string, run worker.CheckFunc) (*worker.Check, error)
Checks *worker.CheckStore
SortAll func(ctx context.Context, runs []worker.SortRun) ([]store.Batch, error)
// Connect logs in to a mail server with credentials that are not stored yet, trying
// the usernames the preset allows, and returns the connection with the username that worked.
Connect func(ctx context.Context, acct store.Account, password string) (mail.Mailbox, string, error)
// StartAccount (re)starts watching an account; StopAccount stops it and waits until
// mail already queued is finished.
StartAccount func(acct store.Account)
StopAccount func(accountID int64)
// Modules are the features compiled in from outside this repository. Their routes are
// served like the built-in ones, and each one's name is on in GET /api/settings
// features. A route of the contract that only a module provides is refused with 404
// not_available while no module serves it.
Modules []ext.Module
// Summary is the summary email; nil = one built from Settings.Env that cannot send.
Summary *summary.Service
}
Options configures the HTTP handler.