settings

package
v1.26.13 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTitle       = "Storyden"
	DefaultDescription = "A forum for the modern age"
	DefaultContent     = `` /* 312-byte string literal not displayed */

)
View Source
const DefaultColour = "hsl(157, 65%, 44%)"
View Source
const StorydenPrimarySettingsKey = "storyden_system"

StorydenPrimarySettingsKey is the key used to store the primary settings data in the database. The settings table itself can contain other settings and is treated as a key-value store. Storyden itself only cares about the row with this key, other rows may be used by plugins or any other integrated systems.

Variables

View Source
var (
	ClientIPModeRemoteAddr        = ClientIPMode{clientIPModeRemoteAddr}
	ClientIPModeSingleHeader      = ClientIPMode{clientIPModeSingleHeader}
	ClientIPModeXFFTrustedProxies = ClientIPMode{clientIPModeXFFTrustedProxies}
)
View Source
var (
	RegistrationModePublic     = RegistrationMode{registrationModePublic}
	RegistrationModeInvitation = RegistrationMode{registrationModeInvitation}
	RegistrationModeDisabled   = RegistrationMode{registrationModeDisabled}
)
View Source
var DefaultSettings = Settings{
	Title:              opt.New(DefaultTitle),
	Description:        opt.New(DefaultDescription),
	Content:            opt.New(defaultContent),
	AccentColour:       opt.New(DefaultColour),
	AuthenticationMode: opt.New(authentication.ModeHandle),
	RegistrationMode:   opt.New(RegistrationModePublic),
	Services: opt.New(ServiceSettings{
		Moderation: opt.New(ModerationServiceSettings{
			ThreadBodyLengthMax: opt.New(60000),
			ReplyBodyLengthMax:  opt.New(10000),
			SignatureLengthMax:  opt.New(500),
		}),
	}),
}

Functions

func NormaliseTrustedProxyCIDRs added in v1.26.7

func NormaliseTrustedProxyCIDRs(values []string) ([]string, []string)

NormaliseTrustedProxyCIDRs trims and normalises trusted proxy values while returning a separate list of invalid entries for validation errors.

func ParseTrustedProxyPrefix added in v1.26.7

func ParseTrustedProxyPrefix(value string) (netip.Prefix, bool)

ParseTrustedProxyPrefix parses a trusted proxy identifier into a normalised prefix. It accepts canonical CIDR, host-form CIDR, and plain IP values.

Types

type ClientIPMode added in v1.26.7

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

func NewClientIPMode added in v1.26.7

func NewClientIPMode(__iNpUt__ string) (ClientIPMode, error)

func (ClientIPMode) Format added in v1.26.7

func (r ClientIPMode) Format(f fmt.State, verb rune)

func (ClientIPMode) MarshalText added in v1.26.7

func (r ClientIPMode) MarshalText() ([]byte, error)

func (*ClientIPMode) Scan added in v1.26.7

func (r *ClientIPMode) Scan(__iNpUt__ any) error

func (ClientIPMode) String added in v1.26.7

func (r ClientIPMode) String() string

func (*ClientIPMode) UnmarshalText added in v1.26.7

func (r *ClientIPMode) UnmarshalText(__iNpUt__ []byte) error

func (ClientIPMode) Value added in v1.26.7

func (r ClientIPMode) Value() (driver.Value, error)

type ClientIPServiceSettings added in v1.26.7

type ClientIPServiceSettings struct {
	ClientIPMode      opt.Optional[ClientIPMode]
	ClientIPHeader    opt.Optional[string]
	TrustedProxyCIDRs opt.Optional[[]string]
}

type MessageOfTheDay

type MessageOfTheDay struct {
	Content  datagraph.Content
	StartAt  opt.Optional[time.Time]
	EndAt    opt.Optional[time.Time]
	Metadata opt.Optional[map[string]any]
}

MessageOfTheDay is a date-bound rich text announcement.

type ModerationServiceSettings

type ModerationServiceSettings struct {
	ThreadBodyLengthMax opt.Optional[int]
	ReplyBodyLengthMax  opt.Optional[int]
	SignatureLengthMax  opt.Optional[int]
	WordBlockList       opt.Optional[[]string]
	WordReportList      opt.Optional[[]string]
}

type RateLimitServiceSettings

type RateLimitServiceSettings struct {
	RateLimit          opt.Optional[int]
	RateLimitPeriod    opt.Optional[time.Duration]
	RateLimitBucket    opt.Optional[time.Duration]
	RateLimitGuestCost opt.Optional[int]
	CostOverrides      opt.Optional[map[string]int]
}

type RegistrationMode added in v1.26.8

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

func NewRegistrationMode added in v1.26.8

func NewRegistrationMode(__iNpUt__ string) (RegistrationMode, error)

func (RegistrationMode) Format added in v1.26.8

func (r RegistrationMode) Format(f fmt.State, verb rune)

func (RegistrationMode) MarshalText added in v1.26.8

func (r RegistrationMode) MarshalText() ([]byte, error)

func (*RegistrationMode) Scan added in v1.26.8

func (r *RegistrationMode) Scan(__iNpUt__ any) error

func (RegistrationMode) String added in v1.26.8

func (r RegistrationMode) String() string

func (*RegistrationMode) UnmarshalText added in v1.26.8

func (r *RegistrationMode) UnmarshalText(__iNpUt__ []byte) error

func (RegistrationMode) Value added in v1.26.8

func (r RegistrationMode) Value() (driver.Value, error)

type RobotProviderSettings added in v1.26.13

type RobotProviderSettings struct {
	Enabled opt.Optional[bool]
	APIKey  opt.Optional[string]
}

type RobotServiceSettings added in v1.26.13

type RobotServiceSettings struct {
	Enabled      opt.Optional[bool]
	DefaultModel opt.Optional[string]
	Providers    opt.Optional[map[string]RobotProviderSettings]
}

type Settings

type Settings struct {
	// Title is the primary name of the instance, it's commonly used for things
	// like <title> tags in HTML for SEO as well as PWA and other app metadata.
	Title opt.Optional[string]

	// Description is similarly used for SEO tags, opengraph and other metadata.
	Description opt.Optional[string]

	// Content is a rich-text "about" field used for describing the instance.
	Content opt.Optional[datagraph.Content]

	// AccentColour is used for controlling frontend brand colour usage. Despite
	// being frontend-specific, it may be used for backend email/SMS templates.
	AccentColour opt.Optional[string]

	// Public is intended to be used to configure public access to the API. If
	// set to false any request to the API will require a verified user account.
	Public opt.Optional[bool]

	// The authentication mode is used to control which authentication methods
	// are exposed to members during the frontend registration and login flows.
	AuthenticationMode opt.Optional[authentication.Mode]

	// The registration mode controls whether unauthenticated visitors may create
	// accounts publicly, only via invitation, or not at all.
	RegistrationMode opt.Optional[RegistrationMode]

	Services opt.Optional[ServiceSettings]

	// Metadata is an arbitrary object which can be used by frontends/clients to
	// store vendor-specific configuration to control the client implementation.
	Metadata opt.Optional[map[string]any]

	// Motd is an optional announcement banner shown to all site visitors.
	Motd opt.Optional[MessageOfTheDay]
}

Settings is the global Storyden settings data that can be changed at runtime.

func (*Settings) Merge

func (s *Settings) Merge(updated Settings) error

Merge will combine "updated" into "s" while overwriting any new values.

type SettingsRepository

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

func New

func New(ctx context.Context, lc fx.Lifecycle, logger *slog.Logger, db *ent.Client, cfg config.Config) (*SettingsRepository, error)

func (*SettingsRepository) Get

func (*SettingsRepository) Set

Set will merge a partial update into the current settings and save new data.

Jump to

Keyboard shortcuts

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