Documentation
¶
Index ¶
- func IsValidFitMode(mode string) bool
- func RegisterRoutes(e *echo.Echo, db *bun.DB, authMiddleware *auth.Middleware)
- func ValidFitModes() []string
- type LibrarySettingsResponse
- type Service
- func (svc *Service) GetLibrarySettings(ctx context.Context, userID, libraryID int) (*models.UserLibrarySettings, error)
- func (svc *Service) GetViewerSettings(ctx context.Context, userID int) (*models.UserSettings, error)
- func (svc *Service) UpdateViewerSettings(ctx context.Context, userID int, preloadCount int, fitMode string) (*models.UserSettings, error)
- func (svc *Service) UpsertLibrarySort(ctx context.Context, userID, libraryID int, sortSpec *string) (*models.UserLibrarySettings, error)
- type UpdateLibrarySettingsPayload
- type ViewerSettingsPayload
- type ViewerSettingsResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidFitMode ¶
IsValidFitMode returns true if the fit mode is valid.
func RegisterRoutes ¶
Types ¶
type LibrarySettingsResponse ¶ added in v0.0.32
type LibrarySettingsResponse struct {
SortSpec *string `json:"sort_spec"`
}
LibrarySettingsResponse is the response for GET/PUT /settings/libraries/:library_id.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) GetLibrarySettings ¶ added in v0.0.32
func (svc *Service) GetLibrarySettings(ctx context.Context, userID, libraryID int) (*models.UserLibrarySettings, error)
GetLibrarySettings returns the (user, library) settings row, or nil when no row exists. The nil-return form (rather than a zero-valued struct) makes callers' "no preference" checks explicit.
func (*Service) GetViewerSettings ¶
func (svc *Service) GetViewerSettings(ctx context.Context, userID int) (*models.UserSettings, error)
GetViewerSettings retrieves viewer settings for a user, returning defaults if none exist.
func (*Service) UpdateViewerSettings ¶
func (svc *Service) UpdateViewerSettings(ctx context.Context, userID int, preloadCount int, fitMode string) (*models.UserSettings, error)
UpdateViewerSettings updates viewer settings for a user, creating if not exists.
func (*Service) UpsertLibrarySort ¶ added in v0.0.32
func (svc *Service) UpsertLibrarySort(ctx context.Context, userID, libraryID int, sortSpec *string) (*models.UserLibrarySettings, error)
UpsertLibrarySort writes just the sort_spec column for (userID, libraryID). sortSpec may be nil to clear the saved default. Other columns on the row (when they exist in a future version) are left untouched by the ON CONFLICT update.
type UpdateLibrarySettingsPayload ¶ added in v0.0.32
type UpdateLibrarySettingsPayload struct {
SortSpec *string `json:"sort_spec" validate:"omitempty,max=200"`
}
UpdateLibrarySettingsPayload is the request body for PUT /settings/libraries/:library_id.
SortSpec is a pointer so the client can distinguish "unset" (omit field from JSON) from "clear the saved default" (send null). A null body clears the saved sort; omitting the field leaves it untouched.
max=200 caps the input length defensively at bind time. The longest possible legitimate spec — every field at the longest direction — fits comfortably under 200 chars (sortspec.MaxLevels=10), so 200 is a generous upper bound that still rejects pathological input before it reaches sortspec.Parse.
type ViewerSettingsPayload ¶
type ViewerSettingsPayload struct {
PreloadCount int `json:"preload_count"`
FitMode string `json:"fit_mode"`
}
ViewerSettingsPayload is the request body for updating viewer settings.
type ViewerSettingsResponse ¶
type ViewerSettingsResponse struct {
PreloadCount int `json:"preload_count"`
FitMode string `json:"fit_mode"`
}
ViewerSettingsResponse is the response for viewer settings.