Documentation
¶
Overview ¶
Package notifypref stores each user's notification preferences (migration 0094, notify_preferences). Today there is one: TmuxAddress, "Show tmux session in notifications" (Account → Notifications), which internal/api's name rule reads when a notification names a mirrored session (names.go there, notifyName; docs/focus.md#a-sessions-name).
🔴 OFF UNLESS THE USER TURNED IT ON. No row, a row the user wrote off, and a read that fails are all off: off is exactly the text every user had before the preference existed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotOwner = errors.New("notifypref: a preference 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 notify_preferences, under row-level security.
func (*PG) SetTmuxAddress ¶
SetTmuxAddress implements Store: the CALLER's row (row-level security refuses another owner's).
func (*PG) TmuxAddress ¶
TmuxAddress implements Store.
🔴 IT REFUSES A ctx THAT ROW-LEVEL SECURITY WOULD BLIND. A row of owner's is invisible to another user's principal and to a principal-less ctx, and would read as "no row" — off — for a user who turned it on: their notifications would silently lose the address on that path. So only owner's own principal or the system scope may read; anything else is an error (the caller reads it as off, and logs it, so the path is found).
type Store ¶
type Store interface {
// TmuxAddress reports whether owner turned on "Show tmux session in
// notifications". No row is false.
TmuxAddress(ctx context.Context, owner int64) (bool, error)
// SetTmuxAddress records owner's choice.
SetTmuxAddress(ctx context.Context, owner int64, on bool) error
}
Store is the per-user notification preferences.