usersettings

package
v1.10.21 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package usersettings owns per-user preferences: the console's look and locale, and which workspace a client lands on when it has none in mind. It is deliberately separate from the account package, which handles account lifecycle rather than taste.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotMember          = errors.New("you are not a member of this workspace")
	ErrInvalidTheme       = errors.New("theme must be one of: system, light, dark")
	ErrInvalidAccent      = errors.New("accent must be one of: default, blue, indigo, slate, orange, lime")
	ErrInvalidLocale      = fmt.Errorf("locale must be one of: %s", strings.Join(models.Locales(), ", "))
	ErrInvalidLandingView = errors.New("landing view is not a known console section")
	ErrInvalidTimezone    = errors.New("timezone must be an IANA time zone name, such as Europe/Paris")
	ErrAccentLocked       = errors.New("the accent is set by your organization")
)

Functions

func ValidTimezone added in v1.10.15

func ValidTimezone(tz string) bool

ValidTimezone reports whether tz is an IANA time zone name the server's tz database knows. "Local" is refused: it names the server's zone, not the user's.

Types

type BrandAccent added in v1.9.6

type BrandAccent func() (accent models.Accent, enforced bool)

BrandAccent supplies the operator's accent and whether it is enforced on every account. A function rather than the branding service itself, so preferences do not depend on branding — the arrow points one way.

type Members

type Members interface {
	FindMember(workspaceID, userID uint) (*models.WorkspaceMember, error)
}

type Service

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

func NewService

func NewService(users Users, settings Settings, members Members) *Service

func (*Service) AdoptFirstWorkspace

func (s *Service) AdoptFirstWorkspace(userID, workspaceID uint)

func (*Service) DefaultWorkspace

func (s *Service) DefaultWorkspace(userID uint) (*models.WorkspaceWithRole, error)

func (*Service) Get

func (s *Service) Get(userID uint) (*models.UserSetting, error)

Get returns a user's preferences, defaulted when they have never saved any.

func (*Service) Save

func (s *Service) Save(userID uint, in Update) (*models.UserSetting, error)

func (*Service) SetBrandAccent added in v1.9.6

func (s *Service) SetBrandAccent(f BrandAccent)

SetBrandAccent wires the operator default (nil-safe: unset means Miabi's own).

func (*Service) SetDefaultWorkspace

func (s *Service) SetDefaultWorkspace(userID uint, workspaceID *uint) error

type Settings

type Settings interface {
	Get(userID uint) (*models.UserSetting, error)
	Save(s *models.UserSetting) error
}

type Update

type Update struct {
	Theme       *string
	Accent      *string
	Timezone    *string
	Locale      *string
	LandingView *string
}

type Users

type Users interface {
	DefaultWorkspace(userID uint) (*models.WorkspaceWithRole, error)
	SetDefaultWorkspace(userID uint, workspaceID *uint) error
	FindByID(id uint) (*models.User, error)
}

Jump to

Keyboard shortcuts

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