Help us shape the future of Go! Take the 2026 Go Developer Survey

notinterested

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package notinterested stores viewer-specific title exclusions. It does not affect ranking or browsing until a caller explicitly applies the preference.

Index

Constants

This section is empty.

Variables

View Source
var ErrForbidden = errors.New("notinterested: viewer or title unavailable")

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Key     core.RatingKey
	AddedAt time.Time
}

type Options

type Options struct {
	DB      *sql.DB
	Active  func(context.Context, int64) (*core.User, error)
	Allowed func(context.Context, *core.User, core.RatingKey) bool
	Changed func(context.Context, int64, core.RatingKey)
	Now     func() time.Time
}

Options supplies the shared database and current authorization checks. Changed is called once after each successful change and never for a no-op.

type Service

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

func New

func New(o Options) (*Service, error)

func (*Service) Generation

func (s *Service) Generation() uint64

Generation changes when a title is hidden or restored.

func (*Service) Has

func (s *Service) Has(ctx context.Context, v *core.User, key core.RatingKey) (bool, error)

func (*Service) HasMany

func (s *Service) HasMany(ctx context.Context, v *core.User, keys []core.RatingKey) (map[core.RatingKey]bool, error)

HasMany reads membership for keys the caller already authorized. It checks the viewer once and issues one query per chunk.

func (*Service) List

func (s *Service) List(ctx context.Context, v *core.User, limit int) ([]Entry, error)

List filters before applying limit; hidden titles never appear in the undo UI. A nonpositive limit returns all permitted entries.

func (*Service) ListUndo

func (s *Service) ListUndo(ctx context.Context, v *core.User) ([]UndoEntry, error)

ListUndo returns opaque handles for all saved exclusions; ordering by handle does not disclose when an inaccessible item was added.

func (*Service) Set

func (s *Service) Set(ctx context.Context, v *core.User, key core.RatingKey, excluded bool) (bool, error)

Set records or undoes an exclusion. Both operations require current access, so knowledge of an old key cannot be used to probe an inaccessible title.

func (*Service) Snapshot

func (s *Service) Snapshot(ctx context.Context, v *core.User) ([]Entry, uint64, error)

Snapshot reads entries and their shared revision in one database statement. The revision changes even if the set returns to an earlier value. Visibility filtering is applied after the database snapshot, before results are returned.

func (*Service) Undo

func (s *Service) Undo(ctx context.Context, v *core.User, handle string) (bool, error)

Undo removes only the current viewer's entry for a handle. For a now-hidden item Changed receives key zero so a notification cannot disclose its identity.

type UndoEntry

type UndoEntry struct {
	Handle string
	Key    core.RatingKey // zero means no current permission to disclose the title
}

UndoEntry exposes no title key or metadata when the title is no longer visible. Handles are random, viewer-bound, and useful only for removal.

Jump to

Keyboard shortcuts

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