Documentation
¶
Overview ¶
Package favorites owns per-viewer favorite identities.
Index ¶
- Variables
- type Entry
- type Kind
- type Options
- type Playlists
- func (p *Playlists) Add(ctx context.Context, uid int64, key core.RatingKey, items []core.RatingKey) error
- func (p *Playlists) Create(ctx context.Context, uid int64, title string, items []core.RatingKey) (*core.Playlist, error)
- func (p *Playlists) Delete(ctx context.Context, uid int64, key core.RatingKey) error
- func (p *Playlists) Get(ctx context.Context, uid int64, key core.RatingKey) (*core.Playlist, error)
- func (p *Playlists) List(ctx context.Context, uid int64) ([]core.Playlist, error)
- func (p *Playlists) Move(ctx context.Context, uid int64, key core.RatingKey, from, to int) error
- func (p *Playlists) Remove(ctx context.Context, uid int64, key core.RatingKey, index int) error
- type Service
- func (s *Service) Generation() uint64
- func (s *Service) Has(ctx context.Context, viewer *core.User, subject Subject) (bool, error)
- func (s *Service) HasTitles(ctx context.Context, viewer *core.User, keys []core.RatingKey) (map[core.RatingKey]bool, error)
- func (s *Service) List(ctx context.Context, viewer *core.User, kind Kind, limit int) ([]Entry, error)
- func (s *Service) Membership(ctx context.Context, viewer *core.User, subject Subject) (bool, *time.Time, error)
- func (s *Service) MirrorEnabled(ctx context.Context, viewer *core.User) (bool, error)
- func (s *Service) MoveTitle(ctx context.Context, viewer *core.User, expected core.RatingKey, from, to int) error
- func (s *Service) Set(ctx context.Context, viewer *core.User, subject Subject, on bool) (bool, error)
- func (s *Service) SetMany(ctx context.Context, viewer *core.User, subjects []Subject, on bool) ([]Subject, error)
- func (s *Service) SetMirror(ctx context.Context, viewer *core.User, enabled bool) error
- func (s *Service) UpdatedAt(ctx context.Context, viewerID int64) (time.Time, error)
- type Subject
Constants ¶
This section is empty.
Variables ¶
var ErrForbidden = errors.New("favorites: viewer or subject unavailable")
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
DB *sql.DB
Active func(context.Context, int64) (*core.User, error)
Allowed func(context.Context, *core.User, Subject) bool
AllowedTitles func(context.Context, *core.User, []core.RatingKey) (bool, error)
Changed func(context.Context, int64, Subject)
Now func() time.Time
Marked core.TransactionalMarkedPlaylists
}
Options requires Marked to use the same DB as DB, so playlist creation and favorite mutations share one transaction. Callbacks must recheck current access.
type Playlists ¶
type Playlists struct {
Base core.Playlists
Favorites *Service
Marked core.MarkedPlaylists
}
Playlists projects the marked Favorites playlist from the authoritative set. The underlying playlist contains no duplicated favorite item list.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) Generation ¶
Generation changes when a favorite is added or removed.
func (*Service) HasTitles ¶
func (s *Service) HasTitles(ctx context.Context, viewer *core.User, keys []core.RatingKey) (map[core.RatingKey]bool, error)
HasTitles checks title membership in bounded batches, revalidating every subject.
func (*Service) List ¶
func (s *Service) List(ctx context.Context, viewer *core.User, kind Kind, limit int) ([]Entry, error)
List returns permitted favorites newest first, without exposing hidden entries.
func (*Service) Membership ¶
func (s *Service) Membership(ctx context.Context, viewer *core.User, subject Subject) (bool, *time.Time, error)
Membership reads one currently authorized favorite without scanning a list. AddedAt is the stored insertion time. It is nil for a stored record without a known positive timestamp, and it is not the title's date added.
func (*Service) MirrorEnabled ¶
SetMirror enables or disables the Plex projection without changing favorites. MirrorEnabled reports whether the viewer's Plex favorites mirror is enabled. Viewers without an explicit setting default to enabled.
func (*Service) MoveTitle ¶
func (s *Service) MoveTitle(ctx context.Context, viewer *core.User, expected core.RatingKey, from, to int) error
MoveTitle preserves hidden entries while changing the ordering of visible titles.
func (*Service) Set ¶
func (s *Service) Set(ctx context.Context, viewer *core.User, subject Subject, on bool) (bool, error)
Set changes one favorite; repeated identical writes emit no event.
func (*Service) SetMany ¶
func (s *Service) SetMany(ctx context.Context, viewer *core.User, subjects []Subject, on bool) ([]Subject, error)
SetMany validates the entire request before changing any favorite and commits all changes together. Repeated subjects and no-op writes emit no event.