notices

package
v0.1.0-alpha.76 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: GPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package notices stores explanatory-notice preferences in the app datastore. It never suppresses operational alerts or grants any application capability.

Index

Constants

View Source
const BrowserLifetime = 365 * 24 * time.Hour

BrowserLifetime bounds both the preference cookie and anonymous record lifetime.

Variables

View Source
var Catalog = func() []Definition {
	var definitions []Definition
	if err := json.Unmarshal(catalogJSON, &definitions); err != nil {
		panic(err)
	}
	return definitions
}()

Catalog is shared with the frontend at build time.

View Source
var ErrUnknown = errors.New("unknown informational notice")

ErrUnknown prevents arbitrary or operational messages from being suppressed.

Functions

func ResetTx

func ResetTx(ctx context.Context, tx *sql.Tx, owner Owner) error

ResetTx restores notices for this account and this browser only.

func SetHiddenTx

func SetHiddenTx(ctx context.Context, tx *sql.Tx, owner Owner, id string, hide bool, now time.Time) error

SetHiddenTx changes one stable notice ID, avoiding lost updates between tabs. The caller revalidates any account session inside this same write transaction.

Types

type Definition

type Definition struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	BrowserOnly bool   `json:"browser_only"`
}

Definition is one stable explanatory notice shared with the UI.

type Owner

type Owner struct{ AccountID, BrowserHash string }

Owner is resolved by the HTTP boundary, never from a request body.

type Snapshot

type Snapshot struct {
	Scope  string   `json:"scope"`
	Hidden []string `json:"hidden"`
}

Snapshot contains only effective preferences, without owner identifiers.

func Read

func Read(ctx context.Context, db *sql.DB, owner Owner, now time.Time) (Snapshot, error)

Read combines the current account's choices with browser-only sign-in choices.

Jump to

Keyboard shortcuts

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