notifypref

package
v0.246.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 5 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 notifypref stores each user's notification preferences (migration 0094, notify_preferences). There are two, independent of each other, both on Account → Notifications:

  • TmuxAddress, "Show tmux sessions", which internal/api's name rule reads when a notification names a mirrored session (names.go there, notifyName; docs/focus.md#show-tmux-sessions);
  • CodenameFirst (migration 0117), "Start notification titles with the tmux name", which internal/api's push title sink reads (server.go goNotify, the title names.go codenameTitle made; docs/focus.md#tmux-name-first-in-push-titles).

And one that is not a notification but is kept beside them, per user, the same way: PagesAgentShare (migration 0135), "Let my agents share pages without asking" on Account → Pages, which internal/api's page_share_request reads for the PAGE'S OWNER (page_tools.go, pageAgentShareOn).

🔴 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

View Source
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 NewPG

func NewPG(pool *pgxpool.Pool) *PG

NewPG is Store over pool.

func (*PG) CodenameFirst added in v0.207.0

func (p *PG) CodenameFirst(ctx context.Context, owner int64) (bool, error)

CodenameFirst implements Store, refusing what TmuxAddress refuses.

func (*PG) PagesAgentShare added in v0.232.0

func (p *PG) PagesAgentShare(ctx context.Context, owner int64) (bool, error)

PagesAgentShare implements Store, refusing what TmuxAddress refuses.

func (*PG) SetCodenameFirst added in v0.207.0

func (p *PG) SetCodenameFirst(ctx context.Context, owner int64, on bool) error

SetCodenameFirst implements Store: the CALLER's row (row-level security refuses another owner's). A new row's tmux_address is its default, off; an existing row's is left as it is.

func (*PG) SetPagesAgentShare added in v0.232.0

func (p *PG) SetPagesAgentShare(ctx context.Context, owner int64, on bool) error

SetPagesAgentShare implements Store: the CALLER's row (row-level security refuses another owner's); an existing row's other choices are left as they are.

func (*PG) SetTmuxAddress

func (p *PG) SetTmuxAddress(ctx context.Context, owner int64, on bool) error

SetTmuxAddress implements Store: the CALLER's row (row-level security refuses another owner's).

func (*PG) TmuxAddress

func (p *PG) TmuxAddress(ctx context.Context, owner int64) (bool, error)

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
	// CodenameFirst reports whether owner turned on "Start notification
	// titles with the tmux name". No row is false.
	CodenameFirst(ctx context.Context, owner int64) (bool, error)
	// SetCodenameFirst records owner's choice, leaving TmuxAddress as it is.
	SetCodenameFirst(ctx context.Context, owner int64, on bool) error
	// PagesAgentShare reports whether owner let their agents share pages
	// without asking. No row is false.
	PagesAgentShare(ctx context.Context, owner int64) (bool, error)
	// SetPagesAgentShare records owner's choice, leaving the others as they are.
	SetPagesAgentShare(ctx context.Context, owner int64, on bool) error
}

Store is the per-user notification preferences.

Jump to

Keyboard shortcuts

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