Documentation
¶
Index ¶
- Variables
- type AdminArtist
- type AdminDeliveryHistory
- type AdminUser
- type Artist
- type ArtistBreakdown
- type ArtistResolution
- type Delivery
- type DeliveryHistory
- type Destination
- type ITunesArtworkArtist
- type ImportInput
- type ImportJob
- type ImportRow
- type ListenBrainzStats
- type MaintenanceStats
- type ManualSyncRequest
- type NotificationPreferences
- type ProviderHealth
- type Release
- type ReleaseBatch
- type ReleaseDetail
- type ReleaseObservation
- type ResolutionCandidate
- type Session
- type SpotifyPollingState
- type Store
- func (s *Store) AddDestination(ctx context.Context, userID int64, name, service string, encrypted []byte) error
- func (s *Store) AdminArtists(ctx context.Context) ([]AdminArtist, error)
- func (s *Store) AdminDeliveryHistory(ctx context.Context, limit, offset int) ([]AdminDeliveryHistory, error)
- func (s *Store) AdminDeliveryHistoryCount(ctx context.Context) (int, error)
- func (s *Store) AdminUsers(ctx context.Context) ([]AdminUser, error)
- func (s *Store) ApplicationLogs(ctx context.Context, limit int) ([]logging.Entry, error)
- func (s *Store) ApplyITunesArtworkBackfill(ctx context.Context, artistID int64, releases []Release, observed time.Time) (checked, updated int, err error)
- func (s *Store) ApplyReleaseBatches(ctx context.Context, artist Artist, batches []ReleaseBatch, observed time.Time) error
- func (s *Store) ApplyReleaseSync(ctx context.Context, artist Artist, releases []Release, observed time.Time) error
- func (s *Store) ArtistByID(ctx context.Context, id int64) (Artist, error)
- func (s *Store) ArtistByMBID(ctx context.Context, mbid string) (Artist, error)
- func (s *Store) ArtistGenres(ctx context.Context, artistID int64) ([]string, error)
- func (s *Store) ArtistResolution(ctx context.Context, userID, resolutionID int64) (ArtistResolution, error)
- func (s *Store) ArtistResolutions(ctx context.Context, userID int64) ([]ArtistResolution, error)
- func (s *Store) ArtistsDue(ctx context.Context, now time.Time, limit int) ([]Artist, error)
- func (s *Store) CancelArtistResolution(ctx context.Context, userID, resolutionID int64) error
- func (s *Store) ClaimManualSyncRequests(ctx context.Context, limit int) ([]ManualSyncRequest, error)
- func (s *Store) ClearLoginFailures(ctx context.Context, key string)
- func (s *Store) Close() error
- func (s *Store) CompleteArtistResolution(ctx context.Context, resolution ArtistResolution, artist Artist) (Artist, bool, error)
- func (s *Store) CompleteManualSyncRequest(ctx context.Context, id int64, syncErr error) error
- func (s *Store) ConsumeAuthToken(ctx context.Context, raw, kind string) (email string, userID *int64, err error)
- func (s *Store) CreateArtistResolution(ctx context.Context, userID int64, args ...string) (ArtistResolution, bool, error)
- func (s *Store) CreateArtistResolutionForProvider(ctx context.Context, userID int64, ...) (ArtistResolution, bool, error)
- func (s *Store) CreateAuthToken(ctx context.Context, kind, email string, userID *int64, creator int64, ...) (string, error)
- func (s *Store) CreateImportJob(ctx context.Context, userID int64) (ImportJob, error)
- func (s *Store) CreateManualSyncRequest(ctx context.Context, userID int64, scope string, artistID *int64) (ManualSyncRequest, error)
- func (s *Store) CreateSession(ctx context.Context, userID int64, ttl time.Duration) (raw, csrf string, err error)
- func (s *Store) CreateUser(ctx context.Context, email, hash, role, timezone string, usernames ...string) (int64, error)
- func (s *Store) CreateUserFromInvite(ctx context.Context, raw, hash, username, timezone string) error
- func (s *Store) DashboardReleases(ctx context.Context, userID int64, today string, limit int) (upcoming []Release, recent []Release, err error)
- func (s *Store) DeleteDestination(ctx context.Context, userID, id int64) error
- func (s *Store) DeleteSession(ctx context.Context, raw string) error
- func (s *Store) DeleteUser(ctx context.Context, actingAdminID, userID int64) error
- func (s *Store) DeliveryHistory(ctx context.Context, userID int64, limit int) ([]DeliveryHistory, error)
- func (s *Store) Destination(ctx context.Context, userID, id int64) (Destination, error)
- func (s *Store) Destinations(ctx context.Context, userID int64) ([]Destination, error)
- func (s *Store) DueArtistResolutions(ctx context.Context, now time.Time, limit int) ([]ArtistResolution, error)
- func (s *Store) DueDeliveries(ctx context.Context, now time.Time, limit int) ([]Delivery, error)
- func (s *Store) DueITunesArtworkArtist(ctx context.Context, now time.Time) (ITunesArtworkArtist, bool, error)
- func (s *Store) DueListenBrainzArtists(ctx context.Context, now time.Time, limit int) ([]Artist, error)
- func (s *Store) EnqueueEvent(ctx context.Context, userID, releaseID int64, eventType, title, body string, ...) error
- func (s *Store) Follow(ctx context.Context, userID, artistID int64) (bool, error)
- func (s *Store) FollowedArtistCount(ctx context.Context, userID int64) (int, error)
- func (s *Store) FollowedArtists(ctx context.Context, userID int64) ([]Artist, error)
- func (s *Store) FollowedArtistsFiltered(ctx context.Context, userID int64, genre, country, artistType string) ([]Artist, error)
- func (s *Store) FollowedBreakdown(ctx context.Context, userID int64, dimension string) ([]ArtistBreakdown, error)
- func (s *Store) Healthy(ctx context.Context) error
- func (s *Store) ImportJob(ctx context.Context, userID, jobID int64) (ImportJob, error)
- func (s *Store) InsertApplicationLog(ctx context.Context, entry logging.Entry) error
- func (s *Store) IsFollowing(ctx context.Context, userID, artistID int64) (bool, error)
- func (s *Store) LatestSpotifyReleaseDate(ctx context.Context, artistID int64) (string, error)
- func (s *Store) LoginAllowed(ctx context.Context, key string) (bool, error)
- func (s *Store) ManualSyncRequests(ctx context.Context, limit int) ([]ManualSyncRequest, error)
- func (s *Store) MarkAllArtistsDue(ctx context.Context) error
- func (s *Store) MarkArtistChecked(ctx context.Context, artistID int64, now time.Time, interval time.Duration) error
- func (s *Store) MarkArtistResolutionReview(ctx context.Context, userID, resolutionID int64, ...) error
- func (s *Store) MarkDeliveryFailed(ctx context.Context, id int64, attempts int, message string, now time.Time) error
- func (s *Store) MarkDeliverySent(ctx context.Context, id int64, now time.Time) error
- func (s *Store) MarkSpotifyChecked(ctx context.Context, artistID int64, now time.Time, interval time.Duration) error
- func (s *Store) MarkSpotifyCheckedAdaptive(ctx context.Context, artistID int64, now time.Time, interval time.Duration, ...) error
- func (s *Store) NotificationPreferences(ctx context.Context, userID int64) (NotificationPreferences, error)
- func (s *Store) ProviderHealth(ctx context.Context) ([]ProviderHealth, error)
- func (s *Store) ProviderHealthByName(ctx context.Context, provider string) (ProviderHealth, error)
- func (s *Store) PruneApplicationLogs(ctx context.Context, before time.Time) error
- func (s *Store) PruneExpiredState(ctx context.Context, now time.Time) (MaintenanceStats, error)
- func (s *Store) QueueDueReleaseDays(ctx context.Context, now time.Time) error
- func (s *Store) RecentReleases(ctx context.Context, userID int64, limit int) ([]Release, error)
- func (s *Store) RecordLoginFailure(ctx context.Context, key string) error
- func (s *Store) ReleaseDetail(ctx context.Context, userID, releaseID int64) (ReleaseDetail, error)
- func (s *Store) RenameDestination(ctx context.Context, userID, destinationID int64, name string) error
- func (s *Store) RetryArtistResolution(ctx context.Context, userID, resolutionID int64, attempts int, next time.Time, ...) error
- func (s *Store) SaveArtistGenres(ctx context.Context, artistID int64, genres []string) error
- func (s *Store) SaveImportRow(ctx context.Context, userID, jobID int64, input ImportInput) (ImportRow, error)
- func (s *Store) SaveListenBrainzStats(ctx context.Context, stats map[int64]ListenBrainzStats, now, next time.Time) error
- func (s *Store) ScheduleArtistCheck(ctx context.Context, artistID int64, next time.Time) error
- func (s *Store) ScheduleITunesArtworkRetry(ctx context.Context, artistID int64, next time.Time) error
- func (s *Store) ScheduleListenBrainzRetry(ctx context.Context, artistIDs []int64, next time.Time, message string) error
- func (s *Store) ScheduleSpotifyCheck(ctx context.Context, artistID int64, next time.Time) error
- func (s *Store) Session(ctx context.Context, raw string) (Session, error)
- func (s *Store) SpotifyBatchChanged(ctx context.Context, releases []Release) (bool, error)
- func (s *Store) SpotifyPollingState(ctx context.Context, artistID int64) (SpotifyPollingState, error)
- func (s *Store) TopListenBrainzArtists(ctx context.Context, userID int64, limit int) ([]Artist, error)
- func (s *Store) Unfollow(ctx context.Context, userID, artistID int64) error
- func (s *Store) UpdateNotificationPreferences(ctx context.Context, p NotificationPreferences) error
- func (s *Store) UpdatePassword(ctx context.Context, userID int64, hash string) error
- func (s *Store) UpdateProfile(ctx context.Context, userID int64, timezone, reminder string, ...) error
- func (s *Store) UpsertArtist(ctx context.Context, a Artist) (Artist, error)
- func (s *Store) UpsertProviderHealth(ctx context.Context, provider string, success bool, next *time.Time, ...) error
- func (s *Store) UserByEmail(ctx context.Context, email string) (User, error)
- func (s *Store) UserByID(ctx context.Context, id int64) (User, error)
- func (s *Store) UserCount(ctx context.Context) (int, error)
- type User
Constants ¶
This section is empty.
Variables ¶
var ( ErrAdminRequired = errors.New("administrator access is required") ErrCannotDeleteSelf = errors.New("you cannot delete your own account") ErrLastAdmin = errors.New("the last administrator cannot be deleted") ErrInvalidUsername = errors.New("username must be 3-32 characters using letters, numbers, dots, underscores, or hyphens") ErrUsernameTaken = errors.New("that username is already in use") )
Functions ¶
This section is empty.
Types ¶
type AdminArtist ¶
type AdminDeliveryHistory ¶
type Artist ¶
type Artist struct {
ID int64
MBID string
Name string
SortName string
Type string
Country string
Disambiguation string
SpotifyID string
SpotifyURL string
SpotifyImageURL string
Genres []string
ListenCount int64
ListenUsers int64
ListenCheckedAt *time.Time
LastCheckedAt *time.Time
SpotifyNextCheckAt *time.Time
BaselineSynced bool
}
type ArtistBreakdown ¶ added in v0.15.0
type ArtistResolution ¶
type DeliveryHistory ¶
type Destination ¶
type ITunesArtworkArtist ¶ added in v0.12.1
ITunesArtworkArtist identifies one artist whose existing iTunes releases are due for an artwork-only refresh. Artwork backfills deliberately operate on existing rows and never create releases or notification events.
type ImportInput ¶
type ImportInput struct {
SourceValue string
DisplayName string
MBID string
MBURL string
SpotifyID string
SpotifyURL string
Reason string
}
ImportInput is a validated ArtistTrackarr export row. Validation belongs to the web package; the store deliberately accepts only the canonical fields needed to create a local artist and follow.
type ImportJob ¶
type ImportJob struct {
ID int64
UserID int64
CreatedAt time.Time
Rows []ImportRow
Added int
AlreadyFollowed int
Invalid int
}
ImportJob is the owner-scoped record for one CSV upload.
type ImportRow ¶
type ImportRow struct {
ID int64
JobID int64
SourceValue string
DisplayName string
Status string
ArtistID *int64
Reason string
}
ImportRow records the independent result for one CSV data row.
type ListenBrainzStats ¶ added in v0.15.0
type MaintenanceStats ¶
type MaintenanceStats struct {
Sessions int64
AuthTokens int64
LoginAttempts int64
ManualSyncs int64
ImportJobs int64
}
PruneExpiredState removes only expired or completed transient state. It deliberately leaves active sessions, current login blocks, queued work, and notification/delivery history untouched.
type ManualSyncRequest ¶
type NotificationPreferences ¶
type ProviderHealth ¶
type Release ¶
type Release struct {
ID int64
MBID string
ArtistID int64
ArtistName string
Title string
PrimaryType string
SecondaryTypes []string
FirstReleaseDate string
DatePrecision int
MusicBrainzURL string
SpotifyID string
SpotifyURL string
SpotifyImageURL string
ITunesID string
ITunesURL string
ITunesArtworkURL string
Source string
FirstObservedAt time.Time
}
type ReleaseBatch ¶
type ReleaseDetail ¶
type ReleaseDetail struct {
Release
Observations []ReleaseObservation
}
type ReleaseObservation ¶
type ResolutionCandidate ¶
type ResolutionCandidate struct {
MBID string `json:"mbid"`
Name string `json:"name"`
SortName string `json:"sort_name"`
Type string `json:"type"`
Country string `json:"country"`
Disambiguation string `json:"disambiguation"`
Aliases []string `json:"aliases,omitempty"`
Genres []string `json:"genres,omitempty"`
Score int `json:"score"`
}
func (ResolutionCandidate) Artist ¶
func (c ResolutionCandidate) Artist() Artist
type SpotifyPollingState ¶
type Store ¶
func (*Store) AddDestination ¶
func (*Store) AdminArtists ¶
func (s *Store) AdminArtists(ctx context.Context) ([]AdminArtist, error)
func (*Store) AdminDeliveryHistory ¶
func (*Store) AdminDeliveryHistoryCount ¶
func (*Store) ApplicationLogs ¶
func (*Store) ApplyITunesArtworkBackfill ¶ added in v0.12.1
func (s *Store) ApplyITunesArtworkBackfill(ctx context.Context, artistID int64, releases []Release, observed time.Time) (checked, updated int, err error)
ApplyITunesArtworkBackfill updates only already persisted release rows. A successful response without artwork receives a long negative-cache period; it does not affect normal catalog scheduling or notifications.
func (*Store) ApplyReleaseBatches ¶
func (*Store) ApplyReleaseSync ¶
func (*Store) ArtistByID ¶
func (*Store) ArtistByMBID ¶
func (*Store) ArtistGenres ¶ added in v0.15.0
func (*Store) ArtistResolution ¶
func (*Store) ArtistResolutions ¶
func (*Store) ArtistsDue ¶
func (*Store) CancelArtistResolution ¶
func (*Store) ClaimManualSyncRequests ¶
func (*Store) ClearLoginFailures ¶
func (*Store) CompleteArtistResolution ¶
func (*Store) CompleteManualSyncRequest ¶
func (*Store) ConsumeAuthToken ¶
func (*Store) CreateArtistResolution ¶
func (s *Store) CreateArtistResolution(ctx context.Context, userID int64, args ...string) (ArtistResolution, bool, error)
CreateArtistResolution accepts the legacy Spotify argument list (providerID, name, URL, imageURL) and the generalized provider-aware list (provider, providerID, name, URL, imageURL). Keeping the legacy form source-compatible lets existing integrations upgrade without a flag day.
func (*Store) CreateArtistResolutionForProvider ¶
func (*Store) CreateAuthToken ¶
func (*Store) CreateImportJob ¶
func (*Store) CreateManualSyncRequest ¶
func (*Store) CreateSession ¶
func (*Store) CreateUser ¶
func (s *Store) CreateUser(ctx context.Context, email, hash, role, timezone string, usernames ...string) (int64, error)
CreateUser accepts an optional username to keep internal callers and integrations built against earlier versions source-compatible. When omitted or empty, a deterministic username is generated from the email address.
func (*Store) CreateUserFromInvite ¶ added in v0.16.0
func (s *Store) CreateUserFromInvite(ctx context.Context, raw, hash, username, timezone string) error
CreateUserFromInvite consumes an invitation and creates its account in one transaction. Validation and uniqueness failures therefore leave the token available for correction and retry.
func (*Store) DashboardReleases ¶
func (*Store) DeleteDestination ¶
func (*Store) DeleteUser ¶
func (*Store) DeliveryHistory ¶
func (*Store) Destination ¶
func (*Store) Destinations ¶
func (*Store) DueArtistResolutions ¶
func (*Store) DueDeliveries ¶
func (*Store) DueITunesArtworkArtist ¶ added in v0.12.1
func (s *Store) DueITunesArtworkArtist(ctx context.Context, now time.Time) (ITunesArtworkArtist, bool, error)
DueITunesArtworkArtist returns at most one artist per call so the background runner can spread artwork requests over time and respect Apple's limiter.
func (*Store) DueListenBrainzArtists ¶ added in v0.15.0
func (*Store) EnqueueEvent ¶
func (*Store) FollowedArtistCount ¶
func (*Store) FollowedArtists ¶
func (*Store) FollowedArtistsFiltered ¶ added in v0.15.0
func (*Store) FollowedBreakdown ¶ added in v0.15.0
func (*Store) InsertApplicationLog ¶
func (*Store) IsFollowing ¶
func (*Store) LatestSpotifyReleaseDate ¶
func (*Store) LoginAllowed ¶
func (*Store) ManualSyncRequests ¶
func (*Store) MarkArtistChecked ¶
func (*Store) MarkArtistResolutionReview ¶
func (*Store) MarkDeliveryFailed ¶
func (*Store) MarkDeliverySent ¶
func (*Store) MarkSpotifyChecked ¶
func (*Store) MarkSpotifyCheckedAdaptive ¶
func (*Store) NotificationPreferences ¶
func (*Store) ProviderHealth ¶
func (s *Store) ProviderHealth(ctx context.Context) ([]ProviderHealth, error)
func (*Store) ProviderHealthByName ¶
ProviderHealthByName returns the persisted state for one provider. The scheduler uses the next check time to carry a provider-wide cooldown across process restarts, so a quota response cannot cause a fresh burst of calls after the container is recreated.
func (*Store) PruneApplicationLogs ¶
func (*Store) PruneExpiredState ¶
func (*Store) QueueDueReleaseDays ¶
func (*Store) RecentReleases ¶
func (*Store) RecordLoginFailure ¶
func (*Store) ReleaseDetail ¶
func (*Store) RenameDestination ¶
func (*Store) RetryArtistResolution ¶
func (*Store) SaveArtistGenres ¶ added in v0.15.0
func (*Store) SaveImportRow ¶
func (s *Store) SaveImportRow(ctx context.Context, userID, jobID int64, input ImportInput) (ImportRow, error)
SaveImportRow persists one row and, for valid input, creates or reuses the canonical artist and owner-scoped follow in the same transaction. This makes partial uploads durable without coupling them to provider availability.
func (*Store) SaveListenBrainzStats ¶ added in v0.15.0
func (*Store) ScheduleArtistCheck ¶
func (*Store) ScheduleITunesArtworkRetry ¶ added in v0.12.1
func (s *Store) ScheduleITunesArtworkRetry(ctx context.Context, artistID int64, next time.Time) error
ScheduleITunesArtworkRetry applies a bounded durable retry time to all existing artwork gaps for an artist after a transient provider failure.
func (*Store) ScheduleListenBrainzRetry ¶ added in v0.15.0
func (*Store) ScheduleSpotifyCheck ¶
func (*Store) SpotifyBatchChanged ¶
SpotifyBatchChanged reports whether a successful provider response contains a release that is new or has changed since it was last observed. It is intentionally read before the release transaction so the scheduler can persist its adaptive state together with the completed observation.
func (*Store) SpotifyPollingState ¶
func (*Store) TopListenBrainzArtists ¶ added in v0.15.0
func (*Store) UpdateNotificationPreferences ¶
func (s *Store) UpdateNotificationPreferences(ctx context.Context, p NotificationPreferences) error