admin

package
v0.3.17 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: GPL-3.0 Imports: 69 Imported by: 0

Documentation

Overview

Package admin is Ether's owner-facing HTTP surface: the JSON API under /ether/api/ and the embedded React SPA (setup wizard, dashboard, settings, logs, resolver traces) served under /ether/.

The package deliberately depends only on internal/config, internal/core (for types) and the small interfaces/funcs declared in Deps; internal/app wires the real implementations. The SPA is embedded in the same binary, so every endpoint it calls is always present: the component deps in Deps are required, and a handler only reaches the deps its routes use.

Mounting:

mux.Handle("/ether/", admin.New(admin.Deps{Config: store, ...}))

The handler accepts both "/ether/..." paths and paths already stripped of the prefix (http.StripPrefix style).

Logging: pass a shared ring buffer so the Logs page can tail the server:

buf := admin.NewLogBuffer(2000)
logger := slog.New(admin.TeeHandler(slog.NewTextHandler(os.Stderr, nil), buf))
h := admin.New(admin.Deps{Config: store, Logs: buf, Logger: logger, ...})

Index

Constants

View Source
const (
	StreamDashboard     = "dashboard"
	StreamExtendChanged = "extend.changed"
	StreamPluginsChange = "plugins.changed"
	StreamPluginsLog    = "plugins.log"
	StreamStudioReload  = "studio.reload"
	StreamAgentApproval = "agent.approval"
	StreamNotice        = "notice"
	// StreamSessions says the set of live streams changed. It carries no
	// list: Overview and Activity both refetch GET /api/status/sessions, so
	// they always show the same streams.
	StreamSessions = "sessions.changed"
	// StreamFlowsChanged announces flow definition changes (create, update,
	// delete, enable, disable, webhook token rotation, auto-disable).
	StreamFlowsChanged = "flows.changed"
	// StreamFlowRun announces flow run lifecycle and step progress updates.
	StreamFlowRun = "flows.run"
)

Console event types pushed over GET /api/stream (WS2). The set is closed: WS4, WS7 and WS11 raise events through consoleStreamRuntime.Publish, which rejects anything outside this list so a typo never becomes a silent hole.

View Source
const (
	// MaxWebhookBodyBytes caps incoming flow webhook request bodies (256 KiB).
	MaxWebhookBodyBytes int64 = 256 << 10
)
View Source
const RedactedSecret = "••••"

RedactedSecret is the placeholder shown in place of a stored secret. A PUT that sends it back unchanged preserves the stored value.

Variables

View Source
var (
	ErrPlexAccountMismatch   = errors.New("plex account does not belong to this viewer")
	ErrPlexWatchRevoked      = errors.New("plex rejected this viewer's token")
	ErrPlexWatchNotConnected = errors.New("this viewer has not connected a Plex account")
	ErrPlexWatchDirectionOff = errors.New("that sync direction is off for this viewer")
)

Sentinels returned by the app adapter so this package does not import the watch client.

View Source
var (
	ErrTraktNotConfigured = errors.New("trakt is not configured")
	ErrTraktNoDeviceCode  = errors.New("no pending trakt device code")
)

Sentinels returned by the app adapter so this package does not import internal/trakt directly.

View Source
var ErrVelaAppIconTooLarge = errors.New("app icon exceeds 512 KB")

ErrVelaAppIconTooLarge indicates an uploaded Vela app icon exceeds 512 KB.

View Source
var ErrVelaWordmarkTooLarge = errors.New("wordmark exceeds 512 KB")

ErrVelaWordmarkTooLarge indicates an uploaded Vela wordmark exceeds 512 KB.

Functions

func BridgeFlowEventsToStream

func BridgeFlowEventsToStream(ctx context.Context, bus *events.Bus, publish func(context.Context, string, any) error) *events.Subscription

BridgeFlowEventsToStream subscribes asynchronously to flows.* events on bus and forwards them to the console SSE publisher (e.g. consoleStreamRuntime.Publish or a StreamHub wrapper). Publishers are never blocked.

func CacheVolumeMounted added in v0.3.0

func CacheVolumeMounted() bool

CacheVolumeMounted reports whether /cache is a mount point. Docker installs bind the segment-cache volume there; a plain directory on the root disk is not the volume.

func ComputeWebhookHMAC

func ComputeWebhookHMAC(secret string, body []byte) string

ComputeWebhookHMAC returns the canonical "sha256=<hex>" HMAC-SHA256 signature of body keyed by secret.

func ConsoleBuilt

func ConsoleBuilt() bool

ConsoleBuilt reports whether this binary was compiled with a built web console bundle in internal/admin/dist (as opposed to the unbuilt placeholder).

func DefaultFlowTemplates

func DefaultFlowTemplates() []flows.Template

DefaultFlowTemplates returns Ether's curated starter flow templates, covering the one-click notification presets and common operational automation recipes.

func DiskFree added in v0.2.4

func DiskFree(path string) (int64, error)

DiskFree reports available bytes on the filesystem containing path.

func DiskUsage added in v0.2.48

func DiskUsage(path string) (total, free int64, err error)

DiskUsage reports the size and free bytes of the volume holding path.

func FlowsStreamHandler

func FlowsStreamHandler(hub *StreamHub, defaultFlowID, defaultRunID string) http.Handler

FlowsStreamHandler serves filtered Server-Sent Events for flow definition changes (flows.changed) and run progress (flows.run) using the shared admin StreamHub patterns: Last-Event-ID resume, retry directive, bounded queue, slow-consumer eviction, and periodic heartbeat comments.

func GeneratedPosterURL

func GeneratedPosterURL(t *core.Title, w int) string

GeneratedPosterURL is the console URL of Ether's poster for a movie or show with no artwork, or "" for any other title. The URL describes the whole image, so it is stable and caches like a TMDB path.

func HashWebhookToken

func HashWebhookToken(token string) string

HashWebhookToken returns the SHA-256 hex digest of a plaintext incoming webhook token. Plaintext tokens are never persisted or echoed after creation.

func ImageURL

func ImageURL(path string, w int) string

ImageURL is the browser-loadable proxy URL of a TMDB image path.

func KnownStreamType added in v0.3.3

func KnownStreamType(typ string) bool

KnownStreamType reports whether typ is a console event type.

func PublishFlowChanged

func PublishFlowChanged(hub *StreamHub, ev FlowChangedEvent) error

PublishFlowChanged pushes a flows.changed SSE event to hub without blocking.

func PublishFlowRun

func PublishFlowRun(hub *StreamHub, ev FlowRunEvent) error

PublishFlowRun pushes a flows.run SSE event to hub without blocking.

func RedactConfig

func RedactConfig(cfg config.Config) config.Config

RedactConfig returns a copy of cfg with every secret replaced by RedactedSecret ("••••"). Empty secrets stay empty so the UI can tell "unset" from "set". The input is not modified.

func SetupOpen added in v0.3.0

func SetupOpen(setupComplete bool, r *http.Request, trusted ...netip.Prefix) bool

SetupOpen is setupOpen for handlers outside the admin API (a failed start's recovery page): whether r gets tokenless local-network access to a server whose setup is not complete.

func Shell added in v0.3.0

func Shell() http.Handler

Shell serves the console's static files without its API, for a server whose settings and database are not open yet (internal/startup's status page). The owner's frame allowlist is not loaded then, so framing is refused outright.

func ShouldAdoptCacheVolume added in v0.3.0

func ShouldAdoptCacheVolume(setupComplete bool, storage, dir, dataDir string, mounted bool) bool

ShouldAdoptCacheVolume is true on a fresh install whose cache folder is still the default inside the config directory and a /cache volume is mounted.

func StreamHandler added in v0.3.3

func StreamHandler(hub *StreamHub) http.Handler

StreamHandler serves GET /api/stream as server-sent events. It sits behind the Extensions mount, so the LAN, token and CSRF boundaries already apply. The console authenticates with the X-Ether-Admin-Token header, which EventSource cannot send, so the console connects with fetch() streaming; the token stays out of the query string.

func TeeHandler

func TeeHandler(next slog.Handler, buf *LogBuffer) slog.Handler

TeeHandler returns an slog.Handler that writes to next and records into buf (e.g. console + in-memory ring for the Logs page).

func UnredactIndexer

func UnredactIndexer(ix config.Indexer, prev config.Config) config.Indexer

UnredactIndexer restores an indexer's API key and secret settings that the UI sent back as placeholders, from the stored config (for tests of unsaved edits run outside this package). A placeholder that is not bound to the stored entry (see UnredactConfig) comes back empty.

Types

type Access added in v0.2.4

type Access struct {
	Owner         bool
	SetupComplete bool
	// SetupPlayback is narrower than setup-page access; it excludes DNS suffixes.
	SetupPlayback bool
}

Access is how requireAuth admitted a request: with a validated owner token, or (Owner false) through tokenless local-network setup access.

func RequestAccess added in v0.2.4

func RequestAccess(ctx context.Context) (a Access, ok bool)

RequestAccess reports how the admin API admitted the request whose context is ctx. Only requireAuth sets it, from its own checks, so extension handlers can demand more than admission (an owner token, a finished setup); ok is false for a request that did not pass through requireAuth.

type CatalogBrowser added in v0.2.9

type CatalogBrowser interface {
	BrowseTitles(context.Context, core.BrowseQuery) (core.Page, error)
}

CatalogBrowser exposes paginated local browsing without a remote TMDB search.

type CatalogExternal added in v0.3.3

type CatalogExternal interface {
	TitlesByIMDB(ctx context.Context, ids []string) []core.Title
}

CatalogExternal names titles by their IMDb ids.

type CatalogHelper

type CatalogHelper interface {
	SearchTitles(ctx context.Context, q string, t core.MediaType, limit int) ([]core.Title, error)
	// Facets: genre, decade, contentRating, studio, country, language.
	Facets(ctx context.Context, t core.MediaType, facet string) ([]core.FacetValue, error)
	// Lookup kinds: person, keyword, company, network, collection, watchProvider.
	Lookup(ctx context.Context, kind, q, region string) ([]core.LookupResult, error)
	TitleDetail(ctx context.Context, key core.RatingKey) (*core.Title, error)
}

CatalogHelper backs /ether/api/catalog/*. Implemented by internal/collections.

type CatalogLibraryControls

type CatalogLibraryControls interface {
	TitleLibraryStatus(ctx context.Context, key core.RatingKey) (catalog.BrowsabilityStatus, error)
	IncludeTitle(ctx context.Context, key core.RatingKey) (catalog.BrowsabilityStatus, error)
	RemoveInclude(ctx context.Context, key core.RatingKey) (catalog.BrowsabilityStatus, error)
}

CatalogLibraryControls exposes per-title browsability explanations and owner library overrides to the console inspector.

type CatalogUnfilteredSearch

type CatalogUnfilteredSearch interface {
	SearchAllTitles(ctx context.Context, q string, t core.MediaType, limit int) ([]core.Title, error)
}

CatalogUnfilteredSearch searches non-adult TMDB and local titles without hiding items excluded by catalogue rules or release gates.

type CollectionStudio

type CollectionStudio interface {
	ListSpecs(ctx context.Context) ([]core.CollectionSpec, error)
	GetSpec(ctx context.Context, id string) (*core.CollectionSpec, error)
	CreateSpec(ctx context.Context, spec core.CollectionSpec) (*core.CollectionSpec, error)
	UpdateSpec(ctx context.Context, id string, spec core.CollectionSpec) (*core.CollectionSpec, error)
	DeleteSpec(ctx context.Context, id string) error
	Preview(ctx context.Context, spec core.CollectionSpec, n int) (*core.CollectionPreview, error)
	Rebuild(ctx context.Context, id string) (*core.CollectionSpec, error)
	Templates() []core.CollectionTemplate
	// Artwork returns the collection's poster at width w.
	Artwork(ctx context.Context, id string, w int) ([]byte, string, time.Time, error)
}

CollectionStudio backs /ether/api/collections*. Implemented by internal/collections.

Errors are mapped by behaviour, so implementations need not import this package: core.ErrNotFound → 404; an error with InvalidFields() map[string]string → 400 with per-field messages; NotConfigured() bool (the owner has not enabled the LLM that Generate drafts with) → 501; Conflict() bool → 409; Upstream() bool → 502.

type ConsoleListenerStatus

type ConsoleListenerStatus struct {
	ConfiguredPort int    `json:"configuredPort"`
	ActivePort     int    `json:"activePort"`
	MainPort       int    `json:"mainPort"`
	OnMainPort     bool   `json:"onMainPort"`
	Fallback       bool   `json:"fallback"`
	Error          string `json:"error,omitempty"`
}

ConsoleListenerStatus describes the active state of the optional dedicated owner console listener, including bind-failure fallback to the main port.

type Deps

type Deps struct {
	ViewerCatalogRules ViewerCatalogRules
	Vela               *veladist.Manager
	VelaSkins          VelaSkinAdmin
	UploadVelaWordmark func(context.Context, io.Reader) (VelaWordmark, error)
	UploadVelaIcon     func(context.Context, io.Reader) (VelaAppIcon, error)
	Frontends          FrontendAdmin
	FavoritesMirror    FavoritesMirror
	NotInterested      NotInterestedPortal
	ViewerAlerts       ViewerAlertPreferences
	ActiveViewer       func(context.Context, int64) (*core.User, error)
	AppAddress         func(context.Context, frontend.Protocol, *http.Request, bool) (string, error)
	ConsoleListener    func() ConsoleListenerStatus
	ViewerPortalURL    func(context.Context, *http.Request) (string, error)
	StremioPortalURL   func(context.Context, *http.Request) (string, error)
	CreateDLNAGuest    func(context.Context) (*core.Viewer, error)
	LocalIdentity      *identity.Local
	IdentityGrants     *identity.Grants
	IdentityLimiter    *identity.LoginLimiter
	// OwnerCredentialChanged runs after an owner local sign-in, setup and
	// any local password change (the app refreshes the owner's recovery
	// sign-in from it). Nil does nothing.
	OwnerCredentialChanged func(context.Context)
	PollLimiter            *identity.LoginLimiter
	QuickConnect           *identity.QuickConnect
	Invites                *identity.Invite
	RefreshViewers         func(context.Context) error
	OwnerConfigured        func(context.Context) bool
	LocalOwnerConfigured   func(context.Context) bool
	// Lifecycle backs pause, resume, sign-out, remove and merge for a
	// viewer (satisfied by *auth.Service). Nil answers those routes 503.
	Lifecycle        ViewerLifecycle
	AuthenticatePlex func(context.Context, string) (*core.User, error)
	LinkPlex         func(context.Context, int64, string) error

	// Extensions are owner-authenticated API subtrees keyed by relative path.
	Extensions map[string]http.Handler
	// PublicExtensions are API subtrees that authorise each request
	// themselves (the add-on settings relay takes a short-lived token).
	PublicExtensions map[string]http.Handler
	ValidateExtra    func(config.Config) []FieldError
	// Config is the owner settings store. Required.
	Config *config.Store
	// Logger defaults to slog.Default().
	Logger *slog.Logger
	// EventBus receives structured auth events (sign-in success/failure).
	EventBus *events.Bus
	// Logs is the in-memory log ring served at /ether/api/logs. A fresh
	// 2000-entry buffer is created when nil (retrieve it via
	// Handler.Logs()); pass a shared one to tail server logs.
	Logs *LogBuffer
	// LogDir holds the on-disk logs offered by GET /api/logs/download;
	// empty offers the in-memory buffer instead.
	LogDir string
	// Support is the in-memory problem-capture recorder. Nil answers the
	// support routes with the same not-found result as an unknown path.
	Support *diagnostics.Recorder
	// Version is reported by /ether/api/bootstrap ("dev" when empty).
	Version string
	// UI overrides the embedded console bundle (tests). Nil serves the
	// embedded internal/admin/dist directory.
	UI fs.FS

	// PlexAuth drives wizard step 1 (plex.tv PIN sign-in and claim).
	PlexAuth PlexAuth

	// SignIn powers "Sign in with Plex" on the admin login screen.
	SignIn SignIn

	// IsOwnerToken reports whether a bearer token (an owner credential or
	// a console session) belongs to the owner.
	IsOwnerToken func(ctx context.Context, token string) bool

	// Sessions backs console sign-in and sign-out.
	Sessions Sessions

	// Provider/integration testers used by the wizard and settings pages.
	TestUsenet  func(ctx context.Context, p config.UsenetProvider) error
	TestIndexer func(ctx context.Context, ix config.Indexer) error
	// TestIndexerIdentity runs a single caps request through the resolved
	// identity for ix under policy.
	TestIndexerIdentity func(ctx context.Context, ix config.Indexer, policy config.ClientIdentity) (config.Identity, error)
	// IndexerPreview renders the masked sample requests for a rule or indexer draft.
	IndexerPreview    func(req IndexerPreviewRequest) (any, error)
	TestDebrid        func(ctx context.Context, p config.DebridProvider) error
	TestTMDB          func(ctx context.Context, key string) error
	TestOpenSubtitles func(ctx context.Context, cfg config.OpenSubtitles) error
	TestSubDL         func(ctx context.Context, cfg config.SubDL) error
	TestLLM           func(ctx context.Context, cfg config.LLM) error
	// LLMModels lists the models the provider in cfg offers.
	LLMModels func(ctx context.Context, cfg config.LLM) ([]LLMModel, error)
	TestTrakt func(ctx context.Context, cfg config.Trakt) error
	// TestIntroDB probes TheIntroDB with the posted key, or the stored key
	// when the post is empty or still redacted.
	TestIntroDB func(ctx context.Context, apiKey string) error
	// TestSkipDB probes SkipDB with the posted key, or the stored key when
	// the post is empty or still redacted. Reading is open, so an empty key
	// probes the public API.
	TestSkipDB func(ctx context.Context, apiKey string) error

	// Dashboard status providers. Each non-nil provider appears on the
	// dashboard and at /ether/api/status/{name}.
	SessionsStatus  StatusFunc // "sessions" — now playing
	CacheStatus     StatusFunc // "cache" — usage; {used,budget} renders as a bar
	ProvidersStatus StatusFunc // "providers" — Usenet provider health
	IndexersStatus  StatusFunc // "indexers" — budgets remaining
	CatalogStatus   StatusFunc // "catalog" — catalogue sync/stats
	// PauseTierMigration pauses (true) or resumes the one-off library-tier
	// migration shown in the catalogue status.
	PauseTierMigration func(ctx context.Context, paused bool) error
	RemoteStatus       StatusFunc // "remote" — remote access
	HWAccelStatus      StatusFunc // "hwaccel" — transcoding hardware

	// CacheRestartRequired reports whether the saved folder/storage differs
	// from the running cache, including changes made during initial setup.
	CacheRestartRequired func() bool
	// SystemLoad is this machine's recent CPU, memory, network and GPU
	// load, served on its own route because only the Overview polls it.
	SystemLoad StatusFunc
	// ExtraStatus adds/overrides named status providers generically. The
	// "widget" entry is required: it backs GET /ether/api/status.
	ExtraStatus map[string]StatusFunc

	// DatabaseCheck runs an owner-requested integrity check. Optional for offline consoles.
	DatabaseCheck StatusFuncE
	// DatabaseCompactStatus reports what compacting the database would take
	// and any compaction running; DatabaseCompact starts one. Both optional.
	DatabaseCompactStatus StatusFuncE
	DatabaseCompact       StatusFuncE

	// ResolverTraces backs GET /ether/api/traces.
	ResolverTraces StatusFuncE

	// Users backs the user-administration and viewer endpoints.
	Users UserStore

	// ViewerDirectory lists stored identities for owner administration, including
	// imported or inactive viewers. It must never be used for authentication.
	// Nil preserves the active-user fallback for smaller integrations.
	ViewerDirectory func(context.Context) ([]ViewerRecord, error)

	// TestTimeout bounds each wizard test call (default 20s).
	TestTimeout time.Duration
	// StatusTimeout bounds each status provider call (default 5s).
	StatusTimeout time.Duration

	// DiskUsage overrides free-space reporting (tests). Nil → OS statfs.
	DiskUsage func(path string) (total, free int64, err error)

	// Personalization backs /api/viewers/*, /api/layout and
	// /api/insights/* (internal/personalize.Engine). Viewers are listed
	// from Users.
	Personalization Personalization
	// LayoutLibraries lists libraries that have Recommended layouts
	// ("library:<id>"). Optional.
	LayoutLibraries func(context.Context) ([]LayoutLibrary, error)
	// PluginLibraryRows lists candidate row descriptors and live shelves for a
	// plugin library's Recommended tab. Optional.
	PluginLibraryRows func(ctx context.Context, viewer *core.User, libraryID int) ([]core.RowDescriptor, []core.HomeRow, error)

	// Collections backs /api/collections* (Collection Studio).
	Collections CollectionStudio
	// CatalogHelper backs /api/catalog/*.
	CatalogHelper CatalogHelper
	// TitleSchedules backs the catalogue drawer's episode and release tabs;
	// nil disables them.
	TitleSchedules      TitleSchedules
	CatalogVisibility   func(context.Context, []core.LibraryExclusion, string, core.LibraryID) (any, error)
	LibraryBrowseFilter func(context.Context, core.LibraryID, core.Filter) (core.Filter, error)
	// WaitingReleaseKeys are in-window movies still hidden from viewers.
	// Nil leaves the waiting catalog filter empty.
	WaitingReleaseKeys func(context.Context) []core.RatingKey
	// Images backs the TMDB image proxy at /api/image.
	Images ImageProxy
	// OwnerArtwork manages uploads independently of the catalog.
	OwnerArtwork interface {
		OwnerStatus() (int, time.Time, bool, error)
		ClearOwner() (bool, error)
	}
	// TitlePosters draws a poster for a title with no artwork.
	TitlePosters interface {
		Title(context.Context, artwork.TitlePoster) ([]byte, string, error)
	}

	// PlexWatch is the per-viewer Plex account watch-state integration.
	// Nil hides the routes.
	PlexWatch PlexWatch

	// Trakt is the per-viewer Trakt OAuth device-code integration.
	// Nil answers 503.
	Trakt Trakt

	// Prerolls backs /api/admin/prerolls*. Nil hides the routes.
	Prerolls Prerolls

	// PlexServers is watch sync with owner-run Plex Media Servers. Nil
	// hides the routes.
	PlexServers PlexServers

	// SharePlexViewer grants library access on plex.tv to the given username,
	// email or user ID for this server. Nil ignores cloud library sharing.
	SharePlexViewer func(ctx context.Context, usernameOrEmail string, userID int64) error

	// Flows backs /api/flows/* (owner-authenticated) and /api/flows/hooks/{token}
	// (incoming webhook ingress outside console auth). Nil hides the routes
	// unless mounted explicitly via Extensions / PublicExtensions.
	Flows *FlowsDeps
}

Deps are the dependencies of the admin handler. The component dependencies (Plex sign-in, testers, traces, users, personalization, collections, catalogue helper, image proxy) are required. Only the tuning knobs, Logger/Logs, the dashboard status providers, Extensions, ValidateExtra, DiskUsage and UI have defaults or may be left empty.

type FavoritesMirror added in v0.3.0

type FavoritesMirror interface {
	MirrorEnabled(context.Context, *core.User) (bool, error)
	SetMirror(context.Context, *core.User, bool) error
}

FavoritesMirror is viewer presentation state, not the favorites themselves.

type FieldError

type FieldError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

FieldError is one validation problem, addressed by dotted field path.

func InstantiateFlowTemplate

func InstantiateFlowTemplate(tmpl flows.Template, name, description string, enabled *bool, params map[string]any) (flows.Flow, []FieldError)

InstantiateFlowTemplate validates params against tmpl.Params and materializes a concrete Flow ready for validation and persistence.

func UnredactConfig

func UnredactConfig(next, prev config.Config) (config.Config, []FieldError)

UnredactConfig restores secrets in next that the client sent back as the redaction placeholder, using prev (the currently stored config). List entries are matched by stable ID only, so reordering a list does not swap secrets. A placeholder whose entry is new, has no ID, or now points somewhere else is not restored: it is reported as a FieldError and left empty.

func ValidateConfig

func ValidateConfig(cfg config.Config) []FieldError

func (FieldError) Error

func (e FieldError) Error() string

type FlowChangedEvent

type FlowChangedEvent struct {
	Action        string    `json:"action"` // created | updated | deleted | enabled | disabled | token_rotated | auto_disabled
	FlowID        string    `json:"flowId"`
	Name          string    `json:"name,omitempty"`
	Version       int       `json:"version,omitempty"`
	Enabled       *bool     `json:"enabled,omitempty"`
	Reason        string    `json:"reason,omitempty"`
	CancelledRuns int       `json:"cancelledRuns,omitempty"`
	At            time.Time `json:"at,omitzero"`
}

FlowChangedEvent is the JSON payload carried by admin.StreamFlowsChanged ("flows.changed") console SSE events.

type FlowLLM

type FlowLLM interface {
	Enabled() bool
	Chat(ctx context.Context, msgs []llm.Message, jsonMode bool) (string, error)
}

FlowLLM is the configured chat model backing POST /api/flows/describe. *llm.Client satisfies it.

type FlowRunEvent

type FlowRunEvent struct {
	RunID      string          `json:"runId"`
	FlowID     string          `json:"flowId"`
	FlowName   string          `json:"flowName,omitempty"`
	EventType  string          `json:"eventType,omitempty"`
	Status     flows.RunStatus `json:"status"`
	DryRun     bool            `json:"dryRun,omitempty"`
	StepCount  int             `json:"stepCount,omitempty"`
	Step       *flows.RunStep  `json:"step,omitempty"`
	Error      string          `json:"error,omitempty"`
	StartedAt  time.Time       `json:"startedAt,omitzero"`
	UpdatedAt  time.Time       `json:"updatedAt,omitzero"`
	FinishedAt time.Time       `json:"finishedAt,omitzero"`
}

FlowRunEvent is the JSON payload carried by admin.StreamFlowRun ("flows.run") console SSE events.

type FlowsAPI

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

FlowsAPI serves the owner-authenticated Flows console API and the public incoming-webhook ingress. Construct it with NewFlowsAPI.

func NewFlowsAPI

func NewFlowsAPI(deps FlowsDeps) *FlowsAPI

NewFlowsAPI builds a FlowsAPI from deps, applying defaults.

func (*FlowsAPI) Handler

func (a *FlowsAPI) Handler() http.Handler

Handler serves the owner-authenticated Flows API with paths relative to the mount point ("/api/flows" stripped), so the app can mount it through Deps.Extensions["flows"] or Deps.Flows. Authentication is the caller's job. The incoming webhook ingress is separate: WebhookHandler.

func (*FlowsAPI) WebhookHandler

func (a *FlowsAPI) WebhookHandler() http.Handler

WebhookHandler serves incoming webhook triggers at /{token} (mounted at /api/flows/hooks/ outside console auth).

type FlowsDeps

type FlowsDeps struct {
	// Store persists flow definitions, runs and steps.
	Store flows.Store
	// Runtime executes manual, webhook and test runs and cancels runs.
	Runtime flows.Runtime
	// Events is the live event schema registry (catalogue + validation).
	Events *events.Registry
	// Actions is the live action registry (catalogue + validation).
	Actions flows.ActionRegistry
	// Triggers lists trigger node kinds for the editor palette. Nil uses
	// the built-in trigger specs.
	Triggers flows.TriggerRegistry
	// Templates overrides the starter template gallery. Nil uses
	// DefaultFlowTemplates.
	Templates []flows.Template
	// StreamHub receives flows.changed / flows.run SSE events and backs
	// GET /api/flows/stream. Nil disables live updates.
	StreamHub *StreamHub
	// PublishStream, when set, replaces direct StreamHub publishing (the
	// app routes it through the cluster console stream so events reach
	// consoles connected to other nodes).
	PublishStream func(ctx context.Context, typ string, data any) error
	// NotifyChannels lists the owner's notification channels and
	// SaveNotifyChannel persists one; both back "Customize as Flow".
	// Nil answers that route 503.
	NotifyChannels    func(ctx context.Context) ([]notify.Channel, error)
	SaveNotifyChannel func(ctx context.Context, ch notify.Channel) error
	// LLM is the configured chat model backing POST /api/flows/describe.
	// Nil or disabled answers 409 ai_unavailable.
	LLM FlowLLM
	// DescribeTimeout bounds POST /api/flows/describe (including any single
	// validation repair pass). Zero defaults to 45 seconds.
	DescribeTimeout time.Duration
	// WebhookHMACSecret optionally resolves a per-flow HMAC secret for
	// incoming webhook signature checks. Nil keys HMAC by the token.
	WebhookHMACSecret func(ctx context.Context, flowID string) (string, bool)
	// WebhookMaxBodyBytes caps incoming webhook bodies. Default 256 KiB.
	WebhookMaxBodyBytes int64
	// WebhookRatePerIP and WebhookRatePerToken bound incoming webhook
	// requests per minute. Zero takes the package defaults.
	WebhookRatePerIP    int
	WebhookRatePerToken int
	// TrustedProxyCIDRs resolves trusted reverse-proxy ranges used to
	// derive the client IP for webhook rate limiting.
	TrustedProxyCIDRs func() []string
	// Logger defaults to slog.Default().
	Logger *slog.Logger
	// Now overrides the clock (tests). Nil uses time.Now.
	Now func() time.Time
	// NewFlowID overrides flow ID generation (tests).
	NewFlowID func() string
}

FlowsDeps wires the Flows console API (docs/design/flows.md §7) to the durable store and runtime provided by internal/flows. Every field is optional: a nil Store or Runtime answers the routes that need it with 503, while validation, catalogues and templates keep working from the registries alone. Handlers never sit on the play path; triggers hand work to the Runtime, which executes asynchronously.

type FrontendAdmin added in v0.3.0

FrontendAdmin is supplied by the app's protocol lifecycle manager.

type FrontendInfo added in v0.3.0

type FrontendInfo struct {
	Descriptor frontend.Descriptor `json:"descriptor"`
	Enabled    bool                `json:"enabled"`
	Status     frontend.Status     `json:"status"`
}

type Handler

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

Handler is the admin HTTP handler. Use NewHandler when you need access to the log buffer the handler created.

func NewHandler

func NewHandler(deps Deps) *Handler

NewHandler builds the admin handler. It panics when Deps.Config is nil.

func (*Handler) Logs

func (h *Handler) Logs() *LogBuffer

Logs returns the log ring served by this handler.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

func (*Handler) SnapshotDashboard added in v0.3.3

func (h *Handler) SnapshotDashboard(ctx context.Context) map[string]any

SnapshotDashboard returns the dashboard payload for contexts without an HTTP request, such as the console stream's push path. It performs the same provider calls as GET /api/dashboard, so it must only run when pushing a change, never on a timer: an idle stream connection costs no database work.

type ImageProxy

type ImageProxy interface {
	Get(ctx context.Context, path string, w int) ([]byte, string, error)
}

ImageProxy serves TMDB artwork by path at the TMDB size covering w. Implemented by internal/artwork. It must reject anything that is not a TMDB image path.

type ImportPlexViewerRequest

type ImportPlexViewerRequest struct {
	ServerID  int64  `json:"serverId"`
	AccountID int64  `json:"accountId"`
	Name      string `json:"name,omitempty"`
}

type IndexerPreviewRequest

type IndexerPreviewRequest struct {
	Rule     *config.IdentityRule  `json:"rule,omitempty"`
	Rules    []config.IdentityRule `json:"rules,omitempty"`
	HasRules bool                  `json:"-"`
	Indexer  *config.Indexer       `json:"indexer,omitempty"`
}

IndexerPreviewRequest is the payload accepted by POST /api/indexer/preview.

type LLMModel added in v0.2.2

type LLMModel struct {
	ID    string `json:"id"`
	Label string `json:"label,omitempty"`
}

LLMModel is one model a language-model provider offers.

type LayoutLibrary

type LayoutLibrary struct {
	ID         int    `json:"id"`
	Name       string `json:"name"`
	Slug       string `json:"slug"`
	Type       string `json:"type"`       // "movie" | "show" | "plugin"
	Section    string `json:"section"`    // "library:<id>"
	Customized bool   `json:"customized"` // true when Global contains section == "library:<id>"
}

LayoutLibrary describes a library whose Recommended tab has its own "library:<id>" layout page.

type LogBuffer

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

LogBuffer is a concurrency-safe ring of recent log records. It backs the Logs page; install its Handler (usually teed with the console handler via TeeHandler) as the server logger.

func NewLogBuffer

func NewLogBuffer(capacity int) *LogBuffer

NewLogBuffer creates a ring holding at most capacity entries (default 2000 when capacity <= 0).

func (*LogBuffer) Add

func (b *LogBuffer) Add(e LogEntry)

Add appends an entry, evicting the oldest when full.

func (*LogBuffer) Clear

func (b *LogBuffer) Clear()

Clear drops all entries.

func (*LogBuffer) Entries

func (b *LogBuffer) Entries(limit int, level, q string) []LogEntry

Entries returns up to limit entries, oldest first. level filters to that level or more severe ("info" includes warn+error); q is a case-insensitive substring over message and attrs. Empty filters match all.

func (*LogBuffer) Handler

func (b *LogBuffer) Handler() slog.Handler

Handler returns an slog.Handler that records into the buffer at slog.LevelDebug and above.

func (*LogBuffer) Len

func (b *LogBuffer) Len() int

Len reports how many entries are retained.

type LogEntry

type LogEntry struct {
	ID      uint64            `json:"id"`
	Time    time.Time         `json:"time"`
	Level   string            `json:"level"`
	Message string            `json:"message"`
	Attrs   map[string]string `json:"attrs,omitempty"`
}

LogEntry is one captured log record.

type MatchPlexViewerRequest

type MatchPlexViewerRequest struct {
	ServerID  int64 `json:"serverId"`
	AccountID int64 `json:"accountId"`
	ViewerID  int64 `json:"viewerId"`
}

type NotInterestedEntry added in v0.3.0

type NotInterestedEntry struct {
	Year       int    `json:"year,omitempty"`
	PosterPath string `json:"posterPath,omitempty"`
	Handle     string `json:"handle"`
	Title      string `json:"title,omitempty"`
	Key        string `json:"key,omitempty"`
}

type NotInterestedPortal added in v0.3.0

type NotInterestedPortal interface {
	ListNotInterested(context.Context, *core.User) ([]NotInterestedEntry, error)
	RestoreNotInterested(context.Context, *core.User, string) (bool, error)
}

type Personalization

type Personalization interface {
	ViewerStats(ctx context.Context, userIDs []int64) (map[int64]core.ViewerStats, error)
	RecentActivity(ctx context.Context, userID int64, limit int) ([]core.ViewerActivity, error)
	Taste(ctx context.Context, user *core.User) (*core.TasteProfile, error)
	SetTasteOverrides(ctx context.Context, user *core.User, overrides []core.TasteOverride) (*core.TasteProfile, error)
	// PreviewHome is what Home (/hubs) or a library's Recommended page
	// ("library:<id>") serves the viewer in the context.
	PreviewHome(ctx context.Context, user *core.User, hc core.HubContext, section string, limit int) (*core.HomePreview, error)
	Refresh(ctx context.Context, user *core.User) error
	// HomeLayout is the saved Home layout document; SetHomeLayout
	// validates and replaces it, applying from the next /hubs request.
	HomeLayout(ctx context.Context) (core.HomeLayout, error)
	SetHomeLayout(ctx context.Context, d core.HomeLayout) (core.HomeLayout, error)
	// PreviewLayout assembles what the viewer would see under a draft
	// document without saving it.
	PreviewLayout(ctx context.Context, user *core.User, hc core.HubContext, section string, limit int, d core.HomeLayout) (*core.HomePreview, error)
	// LayoutDefaults is the default row count per surface (home, library).
	LayoutDefaults() map[string]int
	AvailableRows(ctx context.Context) ([]core.RowDescriptor, error)
	RowInsights(ctx context.Context, days int) ([]core.RowInsight, error)
	// RankerInsight describes the learned ranking model.
	RankerInsight(ctx context.Context) (core.RankerInsight, error)
	Activity(ctx context.Context, days int) ([]core.ActivityDay, error)
}

Personalization is the engine behind the viewers, Home Designer and insights endpoints. Implemented by internal/personalize.Engine.

type PlexAuth

type PlexAuth interface {
	// StartPIN begins the PIN flow: id is the poll handle, code is the
	// 4-character code shown to the owner, authURL is the plex.tv page to open.
	StartPIN(ctx context.Context) (id, code, authURL string, err error)
	// PollPIN reports whether the owner has approved the PIN yet. When done
	// is true the implementation has recorded the owner account for Claim.
	PollPIN(ctx context.Context, id string) (done bool, err error)
	// Claim claims this server to the signed-in account.
	Claim(ctx context.Context) error
	// Status returns a JSON-able snapshot (claimed, owner, connections...).
	Status() any
}

PlexAuth is the plex.tv sign-in/claim surface the wizard needs. Implemented by internal/plextv.

type PlexCandidateAccount

type PlexCandidateAccount struct {
	ServerID              int64  `json:"serverId"`
	ServerName            string `json:"serverName"`
	AccountID             int64  `json:"accountId"`
	AccountName           string `json:"accountName"`
	IsOwner               bool   `json:"isOwner"`
	MatchedViewerID       int64  `json:"matchedViewerId"`
	MatchedViewerName     string `json:"matchedViewerName,omitempty"`
	MatchedViewerUsername string `json:"matchedViewerUsername,omitempty"`
	SuggestedViewerID     int64  `json:"suggestedViewerId,omitempty"`
	SuggestedViewerName   string `json:"suggestedViewerName,omitempty"`
}

type PlexCandidateServer

type PlexCandidateServer struct {
	ServerID   int64                  `json:"serverId"`
	ServerName string                 `json:"serverName"`
	Accounts   []PlexCandidateAccount `json:"accounts"`
}

type PlexFriendSyncer

type PlexFriendSyncer interface {
	SyncFriends(ctx context.Context) error
}

PlexFriendSyncer is an optional capability on PlexAuth for refreshing shared Plex users and their server access tokens on demand.

type PlexServers added in v0.3.4

type PlexServers interface {
	List(ctx context.Context) ([]plexwatch.PMSServer, error)
	ViewerServers(ctx context.Context, userID int64) ([]plexwatch.PMSViewerMapping, error)
	Add(ctx context.Context, name, baseURL, token string) (plexwatch.PMSServer, error)
	Update(ctx context.Context, id int64, name, baseURL, token string) (plexwatch.PMSServer, error)
	SetStepAside(ctx context.Context, id int64, stepAside bool) (plexwatch.PMSServer, error)
	ExplainStepAside(ctx context.Context, key core.RatingKey) (plexwatch.StepAsideExplanation, error)
	Remove(ctx context.Context, id int64) error
	Accounts(ctx context.Context, id int64) ([]plexwatch.PMSAccount, error)
	MapAccount(ctx context.Context, id, accountID int64, in plexwatch.PMSMappingInput) (plexwatch.PMSServer, error)
	SyncNow(ctx context.Context, id int64) (plexwatch.PMSServer, error)
	BackfillPreview(ctx context.Context, id, accountID int64) (plexwatch.PMSBackfillPreview, error)
	BackfillIn(ctx context.Context, id, accountID int64) (plexwatch.PMSServer, error)
	BackfillOut(ctx context.Context, id, accountID int64) (plexwatch.PMSServer, error)
	Unmatched(ctx context.Context, id, userID int64, after string) ([]plexwatch.PMSUnmatched, error)
}

PlexServers is server-to-server watch sync with Plex Media Servers the owner runs (*plexwatch.Servers). Tokens go in and never come back out.

type PlexWatch added in v0.2.57

type PlexWatch interface {
	Status(ctx context.Context, userID, plexID int64) (PlexWatchStatus, error)
	BeginPIN(ctx context.Context, userID, plexID int64) (PlexWatchStatus, error)
	FinishPIN(ctx context.Context, userID, plexID int64) (PlexWatchStatus, error)
	SetDirection(ctx context.Context, userID, plexID int64, direction, interval int) (PlexWatchStatus, error)
	Disconnect(ctx context.Context, userID, plexID int64) (PlexWatchStatus, error)
	Retry(ctx context.Context, userID, plexID int64) (PlexWatchStatus, error)
	ExportCurrent(ctx context.Context, userID, plexID int64) (PlexWatchStatus, error)
	ImportCurrent(ctx context.Context, userID, plexID int64) (PlexWatchStatus, error)
}

PlexWatch is the per-viewer account watch-state integration. Handlers always pass the stored viewer's Plex account id, never the owner's.

type PlexWatchStatus added in v0.2.57

type PlexWatchStatus struct {
	Connected      bool   `json:"connected"`
	PlexID         int64  `json:"plexId,omitempty"`
	Username       string `json:"username,omitempty"`
	Direction      int    `json:"direction"`
	ImportInterval int    `json:"importInterval"`
	LastImport     int64  `json:"lastImport"`
	LastFullImport int64  `json:"lastFullImport"`
	LastSend       int64  `json:"lastSend"`
	NextImport     int64  `json:"nextImport"`
	Problem        string `json:"problem"`
	NeedsReconnect bool   `json:"needsReconnect"`
	Pending        int    `json:"pending"`
	Failed         int    `json:"failed"`
	Restricted     bool   `json:"restricted"`
	PINCode        string `json:"pinCode,omitempty"`
	PINURL         string `json:"pinUrl,omitempty"`
	PINExpires     string `json:"pinExpires,omitempty"`
	AccountMatch   bool   `json:"accountMatch"`
}

PlexWatchStatus is the viewer-facing connection. It never includes a token. Problem is "", "token" (connect again), "rate_limited" or "network".

type Prerolls added in v0.3.3

type Prerolls interface {
	List(ctx context.Context) ([]prerolls.Preroll, string, error)
	Get(ctx context.Context, id string) (prerolls.Preroll, error)
	SetSelection(ctx context.Context, mode string) error
	Create(ctx context.Context, in prerolls.Input) (prerolls.Preroll, error)
	Update(ctx context.Context, id string, in prerolls.Input) (prerolls.Preroll, error)
	Delete(ctx context.Context, id string) error
	Upload(ctx context.Context, id string, r io.Reader) (prerolls.Preroll, error)
	AttachPath(ctx context.Context, id, path string) (prerolls.Preroll, error)
	Plays(ctx context.Context, id string, limit int) ([]prerolls.PlayRow, error)
	Simulate(ctx context.Context, in prerolls.SimulateInput) (prerolls.Decision, error)
	ImportPMS(ctx context.Context, value string) ([]prerolls.Preroll, error)
	Files(ctx context.Context, id string) (video, thumb string, err error)
}

Prerolls is the owner pre-roll service (*prerolls.Service).

type Sessions added in v0.2.48

type Sessions interface {
	// IssueOwnerSession exchanges an owner credential for a session. It
	// fails with core.ErrUnauthorized unless credential is the owner's.
	IssueOwnerSession(ctx context.Context, credential string) (token string, expires time.Time, err error)
	// RevokeOwnerSession ends a session; other tokens are ignored.
	RevokeOwnerSession(ctx context.Context, token string) error
}

Sessions issues and revokes owner console sessions (satisfied by *auth.Service). Sign-in hands the browser a session that only opens this API, never the owner's plex.tv account token.

type SetupStep

type SetupStep struct {
	ID       string `json:"id"`
	Title    string `json:"title"`
	Complete bool   `json:"complete"`
	Required bool   `json:"required"`
	Detail   string `json:"detail,omitempty"`
}

SetupStep is one wizard step's completion state.

func SetupStatus

func SetupStatus(cfg config.Config) (steps []SetupStep, complete bool)

SetupStatus derives wizard progress from the stored config.

type SignIn

type SignIn interface {
	// StartPIN creates a PIN; forwardURL is where plex.tv sends the browser
	// after approval.
	StartPIN(ctx context.Context, forwardURL string) (id, code, authURL string, err error)
	// PINToken returns the account token once approved, "" while pending.
	PINToken(ctx context.Context, id string) (string, error)
}

SignIn is a plex.tv PIN sign-in that, unlike PlexAuth, changes nothing on the server: it only yields the signed-in account's token so the admin UI can authenticate as that account.

type StatusFunc

type StatusFunc func(ctx context.Context) any

StatusFunc returns a JSON-able status blob for a dashboard card. It may return (any, error) shaped values via StatusFuncE; StatusFunc never fails.

type StatusFuncE

type StatusFuncE func(ctx context.Context) (any, error)

StatusFuncE is a StatusFunc that can fail.

type StreamEvent added in v0.3.3

type StreamEvent struct {
	ID   uint64
	Type string
	Data json.RawMessage
}

StreamEvent is one console event. On the wire it is an SSE message with `event:` set to the type, `data:` to the JSON payload and `id:` to the ID.

type StreamHub added in v0.3.3

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

StreamHub is the in-memory fan-out behind GET /api/stream. It is safe for concurrent use. In a cluster every node runs its own hub; the app runtime forwards events between nodes over clusterbus (topic console:event).

func NewStreamHub added in v0.3.3

func NewStreamHub() *StreamHub

NewStreamHub returns an empty hub.

func (*StreamHub) Publish added in v0.3.3

func (h *StreamHub) Publish(typ string, data json.RawMessage) (StreamEvent, error)

Publish appends typ/data to the ring and delivers to every subscriber. Unknown types are rejected. Delivery is non-blocking: a full subscriber is evicted (its channel is closed) so the publisher never waits on a reader.

func (*StreamHub) Subscribe added in v0.3.3

func (h *StreamHub) Subscribe(lastID uint64) (<-chan StreamEvent, func())

Subscribe returns every event after lastID (0 delivers nothing old), then live events until cancel runs. The channel is closed on cancel and when the consumer falls behind and is evicted.

func (*StreamHub) Subscribers

func (h *StreamHub) Subscribers() int

Subscribers is the number of connected consoles.

type TitleCard

type TitleCard struct {
	Key           string  `json:"key"`
	Type          string  `json:"type"`
	Title         string  `json:"title"`
	Year          int     `json:"year,omitempty"`
	Summary       string  `json:"summary,omitempty"`
	Poster        string  `json:"poster,omitempty"`
	Backdrop      string  `json:"backdrop,omitempty"`
	Rating        float64 `json:"rating,omitempty"`
	ContentRating string  `json:"contentRating,omitempty"`
	// ContentRatingSource is where ContentRating came from ("tmdb:US:6",
	// "omdb"); see core.Title.
	ContentRatingSource string   `json:"contentRatingSource,omitempty"`
	RuntimeMinutes      int      `json:"runtimeMinutes,omitempty"`
	Genres              []string `json:"genres,omitempty"`
	ShowTitle           string   `json:"showTitle,omitempty"`
	Season              int      `json:"season,omitempty"`
	Episode             int      `json:"episode,omitempty"`
}

TitleCard is the shared title shape of the owner API.

func CardFor

func CardFor(t core.Title) TitleCard

CardFor converts a catalogue title to a TitleCard.

type TitleSchedules added in v0.3.3

type TitleSchedules interface {
	TitleShowSchedule(ctx context.Context, show core.RatingKey, since time.Time, limit int) (*catalog.ShowSchedule, error)
	TitleSeasonSchedule(ctx context.Context, show core.RatingKey, season int) ([]catalog.DatedEpisode, error)
	MovieReleaseTimeline(ctx context.Context, key core.RatingKey) ([]catalog.ReleaseDate, error)
}

TitleSchedules backs the catalogue drawer's Episodes, Calendar and Releases tabs. Implemented by *catalog.Catalog.

type Trakt

type Trakt interface {
	Status(ctx context.Context, userID int64) (TraktStatus, error)
	StartDevice(ctx context.Context, userID int64) (TraktStatus, error)
	PollDevice(ctx context.Context, userID int64) (TraktStatus, error)
	Disconnect(ctx context.Context, userID int64) (TraktStatus, error)
}

Trakt is the per-viewer Trakt OAuth device-code integration.

type TraktDevice

type TraktDevice struct {
	UserCode        string    `json:"userCode"`
	VerificationURL string    `json:"verificationUrl"`
	ExpiresAt       time.Time `json:"expiresAt"`
	Interval        int       `json:"interval"`
}

TraktDevice is the browser-safe portion of an active Trakt device-code flow. It never includes the secret device_code.

type TraktStatus

type TraktStatus struct {
	Configured bool         `json:"configured"`
	Connected  bool         `json:"connected"`
	Username   string       `json:"username,omitempty"`
	Status     string       `json:"status,omitempty"`
	Device     *TraktDevice `json:"device,omitempty"`
	PortalURL  string       `json:"portalUrl,omitempty"`
}

TraktStatus is a viewer's Trakt connection state. It never includes OAuth access or refresh tokens.

type UserStore

type UserStore interface {
	Users(ctx context.Context) ([]core.User, error)
	UpdateUser(ctx context.Context, u core.User) error
}

UserStore is the user-administration surface (satisfied by core.Auth implementations; only the two admin methods are required here).

type VelaAppIcon

type VelaAppIcon struct {
	URL    string `json:"url"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
	Digest string `json:"digest"`
}

VelaAppIcon is the response returned when an owner uploads a square Vela PWA icon.

type VelaAppIconUploader

type VelaAppIconUploader interface {
	UploadVelaIcon(ctx context.Context, r io.Reader) (VelaAppIcon, error)
}

VelaAppIconUploader is an optional capability on FrontendAdmin for persisting Vela app icons.

type VelaAppIconValidationError

type VelaAppIconValidationError struct {
	Message string
}

VelaAppIconValidationError indicates an uploaded Vela app icon failed format or dimension checks.

func (*VelaAppIconValidationError) Error

type VelaSkin

type VelaSkin struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Version     string   `json:"version"`
	Kind        string   `json:"kind"`
	Builtin     bool     `json:"builtin"`
	Preview     string   `json:"preview,omitempty"`
	Swatches    []string `json:"swatches"`
	InstalledAt int64    `json:"installedAt,omitempty"`
}

VelaSkin describes a built-in or owner-installed Vela skin for the console.

type VelaSkinAdmin

type VelaSkinAdmin interface {
	ListSkins(ctx context.Context) ([]VelaSkin, error)
	InstallSkinArchive(ctx context.Context, pkg []byte) (VelaSkin, error)
	InstallSkinURL(ctx context.Context, rawURL string, lan bool) (VelaSkin, error)
	RemoveSkin(ctx context.Context, id string) error
}

VelaSkinAdmin backs /api/vela/skins*.

type VelaSkinValidationError

type VelaSkinValidationError struct {
	Code    string
	Message string
	Status  int
}

VelaSkinValidationError carries a user-facing validation or policy error.

func (*VelaSkinValidationError) Error

func (e *VelaSkinValidationError) Error() string

type VelaWordmark

type VelaWordmark struct {
	URL    string `json:"url"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
	Digest string `json:"digest"`
}

VelaWordmark is the response returned when an owner uploads a Vela wordmark image.

type VelaWordmarkUploader

type VelaWordmarkUploader interface {
	UploadVelaWordmark(ctx context.Context, r io.Reader) (VelaWordmark, error)
}

VelaWordmarkUploader is an optional capability on FrontendAdmin for persisting Vela wordmarks.

type VelaWordmarkValidationError

type VelaWordmarkValidationError struct {
	Message string
}

VelaWordmarkValidationError indicates an uploaded Vela wordmark failed format or dimension checks.

func (*VelaWordmarkValidationError) Error

type ViewerAlertPreferences added in v0.3.0

type ViewerAlertPreferences interface {
	Enabled(context.Context, *core.User) (bool, error)
	SetEnabled(context.Context, *core.User, bool) error
}

ViewerAlertPreferences stores per-viewer notification preferences.

type ViewerCatalogRules

type ViewerCatalogRules interface {
	RefreshViewerRules(context.Context) error
	ViewerRules(int64) catalog.ViewerRules
	PutViewerRules(context.Context, int64, catalog.ViewerRules) error
	LibraryPolicies() catalog.LibraryPolicies
}

ViewerCatalogRules stores catalogue preferences independently of content safety.

type ViewerLibraryPage

type ViewerLibraryPage struct {
	UserID int64           `json:"userId"`
	Page   core.LayoutPage `json:"page"`
}

ViewerLibraryPage pairs a viewer id with that viewer's override page for a library's Recommended layout.

type ViewerLifecycle added in v0.3.2

type ViewerLifecycle interface {
	PauseViewer(ctx context.Context, viewerID int64) error
	ResumeViewer(ctx context.Context, viewerID int64) error
	RevokeViewerSessions(ctx context.Context, viewerID int64) (int, error)
	RemoveViewer(ctx context.Context, viewerID int64) error
	MergeViewers(ctx context.Context, fromID, intoID int64) error
}

ViewerLifecycle is the people-lifecycle service behind pause, resume, sign-out, remove and merge (satisfied by *auth.Service).

type ViewerRecord added in v0.2.9

type ViewerRecord struct {
	core.User
	Active bool
	Origin string
	// Home is a Plex Home (managed) user. OwnerEnabled is false when the
	// owner paused the viewer. PlexShared is whether plex.tv still
	// shares the server with them. HasPlex is whether they carry a Plex
	// account id.
	Home         bool
	OwnerEnabled bool
	PlexShared   bool
	HasPlex      bool
}

ViewerRecord is a stored identity plus read-only Plex membership metadata. Imported history does not grant server access.

Jump to

Keyboard shortcuts

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