Documentation
¶
Overview ¶
Package settingsapi serves the /api/v1/admin/settings surface: the stored SMTP configuration (#631), the send-test action, the test recipient's notification opt-out status (#1022), the knowledge review-queue alert threshold (#803), the connection-revocation alert's escalation (#1694), and the notification channels a document is delivered to (#1720). It is a decomposition seam of pkg/admin (which sits at the package size budget): the parent registers it on the admin mux and injects the request-scoped helpers it shares with the other admin routes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChannelInput ¶ added in v1.134.0
type ChannelInput struct {
Kind string `json:"kind" example:"mattermost"`
Description string `json:"description,omitempty" example:"Operations alerts"`
Enabled *bool `json:"enabled,omitempty" example:"true"`
Connection string `json:"connection,omitempty" example:"mattermost-bot"`
Target string `json:"target,omitempty" example:"C0123456789"`
Recipients []string `json:"recipients,omitempty"`
Mode string `json:"mode,omitempty" example:"immediate"`
// RepeatAfter is a duration string ("1h", "30m"). Empty applies the
// platform default.
RepeatAfter string `json:"repeat_after,omitempty" example:"1h"`
MaxPerHour int `json:"max_per_hour,omitempty" example:"60"`
}
ChannelInput is the write shape for a notification channel. The name is the path, not a field, so a body cannot rename the channel it is addressed to.
type ChannelListView ¶ added in v1.134.0
type ChannelListView struct {
Channels []ChannelView `json:"channels"`
// Kinds names the kinds this deployment can deliver to, so the admin form
// offers what will work rather than what compiles.
Kinds []string `json:"kinds"`
}
ChannelListView is the collection response.
type ChannelTestResult ¶ added in v1.134.0
ChannelTestResult reports what the channel's upstream said.
type ChannelView ¶ added in v1.134.0
type ChannelView struct {
Name string `json:"name"`
Kind string `json:"kind"`
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled"`
Connection string `json:"connection,omitempty"`
Target string `json:"target,omitempty"`
Recipients []string `json:"recipients,omitempty"`
Mode string `json:"mode"`
RepeatAfter string `json:"repeat_after"`
MaxPerHour int `json:"max_per_hour"`
CreatedBy string `json:"created_by,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
// Warnings report a channel that saves cleanly but cannot deliver -- a
// connection no live toolkit serves. They are warnings rather than
// refusals so an operator can create the channel and the connection in
// either order.
Warnings []string `json:"warnings,omitempty"`
}
ChannelView is the read shape. It carries no credential because a channel holds none: what authorizes a post is the named connection's, and this surface names the connection alone.
type Config ¶
type Config struct {
// Settings persists the admin SMTP configuration. nil disables every
// route in this package.
Settings smtp.SettingsStore
// SendTest delivers a test email through the stored SMTP settings. nil
// disables the test route.
SendTest func(ctx context.Context, to string) error
// Prefs reads per-address notification preferences so the test-send UI
// can surface a target's opt-out state (#1022). nil disables the
// recipient-status route.
Prefs notification.PrefsStore
// ReviewAlert persists the knowledge review-queue alert threshold
// (#803). nil disables the review-queue-alert routes.
ReviewAlert reviewalert.SettingsStore
// ConnectionAlert persists the connection-revocation alert's escalation
// window and recipients (#1694). nil disables the connection-alert
// routes.
ConnectionAlert connalert.SettingsStore
// Channels persists the operator's notification channels (#1720). nil
// disables the channel routes.
Channels notification.ChannelStore
// SendChannelTest delivers a test message through one channel's own
// transport. nil disables the channel test route.
SendChannelTest func(ctx context.Context, name string) error
// ConnectionExists reports whether a live api toolkit serves a
// connection, so a channel naming one that is gone is shown as
// undeliverable rather than as configured. nil omits that warning.
ConnectionExists func(ctx context.Context, name string) bool
// Mutable reports database config mode; false swaps the write routes for
// ReadOnly.
Mutable bool
// Author resolves the acting admin for audit columns.
Author func(*http.Request) string
// Decode is the parent's strict JSON body decoder (unknown fields
// rejected, size-capped); its error text is safe to return as the
// problem detail.
Decode func(w http.ResponseWriter, r *http.Request, dst any) error
// ReadOnly is the parent's 405 not-available-in-file-mode responder.
ReadOnly http.HandlerFunc
}
Config carries the stores and parent-owned helpers the routes need.