Documentation
¶
Overview ¶
Package chiefpref stores each user's choice to turn their chief on or off (migration 0060, chief_preferences). It stores only the CHOICE: whether the chief is on for a user who never chose is internal/api's rule (chiefOn), so the default lives in one place.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotOwner = errors.New("chiefpref: the toggle is read only as its owner or as the system")
ErrNotOwner refuses a read whose ctx can see neither owner's row nor every row.
Functions ¶
This section is empty.
Types ¶
type PG ¶
type PG struct {
// contains filtered or unexported fields
}
PG is Store on chief_preferences, under row-level security.
func (*PG) Choice ¶
Choice implements Store.
🔴 IT REFUSES A ctx THAT ROW-LEVEL SECURITY WOULD BLIND. A row of owner's is invisible to any other user's principal and to a principal-less ctx, and an invisible row reads as "never chose", which falls back to "on if a chief agent exists": a user who turned their chief OFF would get it back on any path that read the toggle with the wrong principal. So only owner's own principal or the system scope may read, and anything else is an error the caller reads as off.
type Store ¶
type Store interface {
// Choice is owner's stored choice: chose is false when owner never
// turned the chief on or off (no row), and on is then meaningless.
Choice(ctx context.Context, owner int64) (chose, on bool, err error)
// SetEnabled records owner's choice.
SetEnabled(ctx context.Context, owner int64, on bool) error
}
Store is the per-user chief toggle.