handlers

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

package handlers implements route handlers

Index

Constants

This section is empty.

Variables

View Source
var (
	NotificationManager = &GlobalNotificationManager{
		notifications: make(map[int32][]Notification),
	}
)

Functions

func AdminDeleteUserHandler added in v0.1.30

func AdminDeleteUserHandler(store db.DB) http.HandlerFunc

Admin only: Delete User

func AdminUpdateUserHandler added in v0.1.30

func AdminUpdateUserHandler(store db.DB) http.HandlerFunc

Admin only: Update User (Promote/Demote or Password Reset)

func AttemptAutoFetchForListen added in v0.1.30

func AttemptAutoFetchForListen(ctx context.Context, store db.DB, user *models.User, trackName, artistName, albumName string)

AttemptAutoFetchForListen checks if metadata needs to be fetched for a new scrobble

func ClearAICacheHandler added in v0.1.30

func ClearAICacheHandler(store db.DB) http.HandlerFunc

ClearAICacheHandler clears the cached AI critiques when prompts are updated

func CreateAliasHandler

func CreateAliasHandler(store db.DB) http.HandlerFunc

CreateAliasHandler creates new aliases for a given artist, album, or track.

func CreateUserHandler added in v0.1.30

func CreateUserHandler(store db.DB) http.HandlerFunc

Admin only: Create User

func DeleteAlbumHandler

func DeleteAlbumHandler(store db.DB) http.HandlerFunc

func DeleteAliasHandler

func DeleteAliasHandler(store db.DB) http.HandlerFunc

DeleteAliasHandler deletes an alias for a given artist or album ID.

func DeleteApiKeyHandler

func DeleteApiKeyHandler(store db.DB) http.HandlerFunc

func DeleteArtistHandler

func DeleteArtistHandler(store db.DB) http.HandlerFunc

func DeleteListenHandler

func DeleteListenHandler(store db.DB) http.HandlerFunc

func DeleteTrackHandler

func DeleteTrackHandler(store db.DB) http.HandlerFunc

func ExportAICacheHandler added in v0.1.30

func ExportAICacheHandler(store db.DB) http.HandlerFunc

ExportAICacheHandler exports only the AI cache data

func ExportHandler

func ExportHandler(store db.DB) http.HandlerFunc

func ExportSpotifyMetadataHandler added in v0.1.30

func ExportSpotifyMetadataHandler(store db.DB) http.HandlerFunc

ExportSpotifyMetadataHandler exports all Spotify metadata to JSON

func GenerateAIPlaylistHandler

func GenerateAIPlaylistHandler(store db.DB) http.HandlerFunc

func GenerateApiKeyHandler

func GenerateApiKeyHandler(store db.DB) http.HandlerFunc

func GetAICritiqueHandler

func GetAICritiqueHandler(store db.DB) http.HandlerFunc

func GetAIProfileCritiqueHandler

func GetAIProfileCritiqueHandler(store db.DB) http.HandlerFunc

func GetAlbumHandler

func GetAlbumHandler(store db.DB) func(w http.ResponseWriter, r *http.Request)

func GetAliasesHandler

func GetAliasesHandler(store db.DB) http.HandlerFunc

GetAliasesHandler retrieves all aliases for a given artist or album ID.

func GetApiKeysHandler

func GetApiKeysHandler(store db.DB) http.HandlerFunc

func GetArtistHandler

func GetArtistHandler(store db.DB) func(w http.ResponseWriter, r *http.Request)

func GetArtistsForItemHandler

func GetArtistsForItemHandler(store db.DB) http.HandlerFunc

func GetBackgroundImageHandler added in v0.1.30

func GetBackgroundImageHandler() http.HandlerFunc

GetBackgroundImageHandler serves background images

func GetCfgHandler

func GetCfgHandler() http.HandlerFunc

func GetClientSourcesHandler added in v0.1.30

func GetClientSourcesHandler(store db.DB) http.HandlerFunc

func GetListenActivityHandler

func GetListenActivityHandler(store db.DB) func(w http.ResponseWriter, r *http.Request)

func GetListensHandler

func GetListensHandler(store db.DB) func(w http.ResponseWriter, r *http.Request)

func GetProfileImageHandler added in v0.1.30

func GetProfileImageHandler() http.HandlerFunc

GetProfileImageHandler serves profile images

func GetTopAlbumsHandler

func GetTopAlbumsHandler(store db.DB) func(w http.ResponseWriter, r *http.Request)

func GetTopArtistsHandler

func GetTopArtistsHandler(store db.DB) func(w http.ResponseWriter, r *http.Request)

func GetTopTracksHandler

func GetTopTracksHandler(store db.DB) func(w http.ResponseWriter, r *http.Request)

func GetTrackHandler

func GetTrackHandler(store db.DB) func(w http.ResponseWriter, r *http.Request)

func GetUserPreferencesHandler

func GetUserPreferencesHandler(store db.DB) http.HandlerFunc

GetUserPreferencesHandler retrieves the user's preferences

func GetUserThemeHandler

func GetUserThemeHandler(store db.DB) http.HandlerFunc

GetUserThemeHandler retrieves the user's saved theme

func HealthHandler

func HealthHandler() http.HandlerFunc

func ImageHandler

func ImageHandler(store db.DB) http.HandlerFunc

func ImportAICacheHandler added in v0.1.30

func ImportAICacheHandler(store db.DB) http.HandlerFunc

ImportAICacheHandler imports AI cache data from a JSON file

func ImportHandler

func ImportHandler(store db.DB, wWorker *worker.Worker) http.HandlerFunc

func ImportSpotifyMetadataHandler added in v0.1.30

func ImportSpotifyMetadataHandler(store db.DB) http.HandlerFunc

ImportSpotifyMetadataHandler imports Spotify metadata from JSON

func LbzSubmitListenHandler

func LbzSubmitListenHandler(store db.DB, mbzc mbz.MusicBrainzCaller) func(w http.ResponseWriter, r *http.Request)

func LbzValidateTokenHandler

func LbzValidateTokenHandler(store db.DB) http.HandlerFunc

func ListUsersHandler added in v0.1.30

func ListUsersHandler(store db.DB) http.HandlerFunc

Admin only: List all users

func LoginHandler

func LoginHandler(store db.DB) http.HandlerFunc

func LogoutHandler

func LogoutHandler(store db.DB) http.HandlerFunc

func MeHandler

func MeHandler(store db.DB) http.HandlerFunc

func MergeArtistsHandler

func MergeArtistsHandler(store db.DB) http.HandlerFunc

func MergeReleaseGroupsHandler

func MergeReleaseGroupsHandler(store db.DB) http.HandlerFunc

func MergeTracksHandler

func MergeTracksHandler(store db.DB) http.HandlerFunc

func NowPlayingHandler

func NowPlayingHandler(store db.DB) http.HandlerFunc

func OptsFromRequest

func OptsFromRequest(r *http.Request) db.GetItemsOpts

func PresencePingHandler added in v0.1.30

func PresencePingHandler(store db.DB) http.HandlerFunc

func PublicProfileHandler

func PublicProfileHandler(store db.DB) http.HandlerFunc

func ReplaceImageHandler

func ReplaceImageHandler(store db.DB) http.HandlerFunc

func SaveUserPreferencesHandler

func SaveUserPreferencesHandler(store db.DB) http.HandlerFunc

SaveUserPreferencesHandler saves the user's preferences

func SaveUserThemeHandler

func SaveUserThemeHandler(store db.DB) http.HandlerFunc

SaveUserThemeHandler saves the user's custom theme

func SearchHandler

func SearchHandler(store db.DB) http.HandlerFunc

func SetPrimaryAliasHandler

func SetPrimaryAliasHandler(store db.DB) http.HandlerFunc

sets the primary alias for albums, artists, and tracks

func SetPrimaryArtistHandler

func SetPrimaryArtistHandler(store db.DB) http.HandlerFunc

func SignupHandler added in v0.1.30

func SignupHandler(store db.DB) http.HandlerFunc

func SpotifyBulkFetchSSEHandler added in v0.1.30

func SpotifyBulkFetchSSEHandler(store db.DB) http.HandlerFunc

SpotifyBulkFetchSSEHandler fetches metadata for ALL entities with real-time progress updates

func SpotifyConfiguredHandler added in v0.1.30

func SpotifyConfiguredHandler(store db.DB) http.HandlerFunc

SpotifyConfiguredHandler checks if Spotify credentials are configured

func SpotifyFetchMetadataHandler added in v0.1.30

func SpotifyFetchMetadataHandler(store db.DB) http.HandlerFunc

SpotifyFetchMetadataHandler fetches and updates metadata for an entity

func SpotifySearchHandler added in v0.1.30

func SpotifySearchHandler(store db.DB) http.HandlerFunc

SpotifySearchHandler searches Spotify for artists, albums, or tracks

func StartFullLibraryFetch added in v0.1.30

func StartFullLibraryFetch(ctx context.Context, store db.DB, user *models.User)

StartFullLibraryFetch runs in the background to fetch the rest of the library

func StatsHandler

func StatsHandler(store db.DB) http.HandlerFunc

func SubmitListenWithIDHandler

func SubmitListenWithIDHandler(store db.DB) http.HandlerFunc

func UpdateAlbumHandler

func UpdateAlbumHandler(store db.DB) http.HandlerFunc

func UpdateApiKeyLabelHandler

func UpdateApiKeyLabelHandler(store db.DB) http.HandlerFunc

func UpdateUserHandler

func UpdateUserHandler(store db.DB) http.HandlerFunc

func UploadBackgroundImageBase64Handler added in v0.1.30

func UploadBackgroundImageBase64Handler(store db.DB) http.HandlerFunc

UploadBackgroundImageBase64Handler handles base64 encoded background image uploads

func UploadProfileImageBase64Handler added in v0.1.30

func UploadProfileImageBase64Handler(store db.DB) http.HandlerFunc

UploadProfileImageBase64Handler handles base64 encoded profile image uploads

func UploadProfileImageHandler added in v0.1.30

func UploadProfileImageHandler(store db.DB) http.HandlerFunc

UploadProfileImageHandler handles profile image uploads

func YearlyRecapHandler

func YearlyRecapHandler(store db.DB) http.HandlerFunc

Types

type AICritiqueRequest

type AICritiqueRequest struct {
	TrackID    int32  `json:"track_id"`
	TrackName  string `json:"track_name"`
	ArtistName string `json:"artist_name"`
	AlbumName  string `json:"album_name"`
}

type AIPlaylistRequest

type AIPlaylistRequest struct {
	Type string `json:"type"` // mood_mix, genre_dive, discover_weekly, etc.
}

type AIPlaylistResponse

type AIPlaylistResponse struct {
	ID          string            `json:"id"`
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Tracks      []AIPlaylistTrack `json:"tracks"`
}

type AIPlaylistTrack

type AIPlaylistTrack struct {
	ID     int64  `json:"id,omitempty"`
	Name   string `json:"name"`
	Artist string `json:"artist"`
	Album  string `json:"album,omitempty"`
	Image  string `json:"image,omitempty"`
}

type AIProfileCritiqueRequest

type AIProfileCritiqueRequest struct {
	Period string `json:"period"`
}

type BeatScrobbleImport

type BeatScrobbleImport struct {
	Version     string                 `json:"version"`
	ExportedAt  time.Time              `json:"exported_at"`
	User        string                 `json:"user"`
	Preferences map[string]interface{} `json:"preferences"`
	Theme       json.RawMessage        `json:"theme"`
	Listens     []interface{}          `json:"listens"`
}

type CachedCritique

type CachedCritique struct {
	Critique  string    `json:"critique"`
	Timestamp time.Time `json:"timestamp"`
}

type GlobalNotificationManager added in v0.1.30

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

GlobalNotificationManager handles user notifications from background processes

func (*GlobalNotificationManager) Add added in v0.1.30

func (nm *GlobalNotificationManager) Add(userID int32, n Notification)

func (*GlobalNotificationManager) GetAndClear added in v0.1.30

func (nm *GlobalNotificationManager) GetAndClear(userID int32) []Notification

type LbzValidateResponse

type LbzValidateResponse struct {
	Code     int    `json:"code"`
	Error    string `json:"error,omitempty"`
	Message  string `json:"message,omitempty"`
	Valid    bool   `json:"valid,omitempty"`
	UserName string `json:"user_name,omitempty"`
}

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type Notification added in v0.1.30

type Notification struct {
	ID        string      `json:"id"`
	Type      string      `json:"type"` // success, error, info
	Message   string      `json:"message"`
	Timestamp time.Time   `json:"timestamp"`
	Data      interface{} `json:"data,omitempty"`
}

type NowPlayingResponse

type NowPlayingResponse struct {
	CurrentlyPlaying bool         `json:"currently_playing"`
	Track            models.Track `json:"track"`
}

type OpenRouterRequest

type OpenRouterRequest struct {
	Model    string    `json:"model"`
	Messages []Message `json:"messages"`
}

type OpenRouterResponse

type OpenRouterResponse struct {
	Choices []struct {
		Message Message `json:"message"`
	} `json:"choices"`
	Error *struct {
		Message string `json:"message"`
	} `json:"error,omitempty"`
}

type ProfileCritiquesCache

type ProfileCritiquesCache map[string]CachedCritique

type PublicAlbumArtist

type PublicAlbumArtist struct {
	Name string `json:"name"`
}

type PublicProfileResponse

type PublicProfileResponse struct {
	Username        string                 `json:"username"`
	Stats           PublicStatsResponse    `json:"stats"`
	TopArtists      []PublicTopArtist      `json:"topArtists"`
	TopAlbums       []PublicTopAlbum       `json:"topAlbums"`
	Theme           json.RawMessage        `json:"theme,omitempty"`
	ProfileImage    string                 `json:"profileImage,omitempty"`
	BackgroundImage string                 `json:"backgroundImage,omitempty"`
	Preferences     map[string]interface{} `json:"preferences,omitempty"`
}

type PublicStatsResponse

type PublicStatsResponse struct {
	ListenCount     int64 `json:"listen_count"`
	ArtistCount     int64 `json:"artist_count"`
	AlbumCount      int64 `json:"album_count"`
	TrackCount      int64 `json:"track_count"`
	MinutesListened int64 `json:"minutes_listened"`
}

type PublicTopAlbum

type PublicTopAlbum struct {
	ID          int64               `json:"id"`
	Title       string              `json:"title"`
	Image       string              `json:"image,omitempty"`
	Artists     []PublicAlbumArtist `json:"artists"`
	ListenCount int64               `json:"listen_count"`
}

type PublicTopArtist

type PublicTopArtist struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Image       string `json:"image,omitempty"`
	ListenCount int64  `json:"listen_count"`
}

type ReplaceImageResponse

type ReplaceImageResponse struct {
	Success bool   `json:"success"`
	Image   string `json:"image"`
	Message string `json:"message,omitempty"`
}

type SearchResults

type SearchResults struct {
	Artists []*models.Artist `json:"artists"`
	Albums  []*models.Album  `json:"albums"`
	Tracks  []*models.Track  `json:"tracks"`
}

type ServerConfig

type ServerConfig struct {
	DefaultTheme string `json:"default_theme"`
	Version      string `json:"version"`
}

type SpotifyAlbumExport added in v0.1.30

type SpotifyAlbumExport struct {
	Title                string   `json:"title"`
	Artist               string   `json:"artist,omitempty"`
	SpotifyID            string   `json:"spotify_id,omitempty"`
	Genres               []string `json:"genres,omitempty"`
	Popularity           int      `json:"popularity,omitempty"`
	ReleaseDate          string   `json:"release_date,omitempty"`
	Label                string   `json:"label,omitempty"`
	ReleaseDatePrecision string   `json:"release_date_precision,omitempty"`
}

type SpotifyArtistExport added in v0.1.30

type SpotifyArtistExport struct {
	Name       string   `json:"name"`
	SpotifyID  string   `json:"spotify_id,omitempty"`
	Genres     []string `json:"genres,omitempty"`
	Popularity int      `json:"popularity,omitempty"`
	Followers  int      `json:"followers,omitempty"`
	Bio        string   `json:"bio,omitempty"`
}

type SpotifyMetadataExport added in v0.1.30

type SpotifyMetadataExport struct {
	Version    string                `json:"version"`
	ExportedAt time.Time             `json:"exported_at"`
	Artists    []SpotifyArtistExport `json:"artists"`
	Albums     []SpotifyAlbumExport  `json:"albums"`
	Tracks     []SpotifyTrackExport  `json:"tracks"`
}

SpotifyMetadataExport is the structure for the export JSON

type SpotifySearchResponse added in v0.1.30

type SpotifySearchResponse struct {
	Results []SpotifySearchResult `json:"results"`
}

SpotifySearchResponse is the API response

type SpotifySearchResult added in v0.1.30

type SpotifySearchResult struct {
	ID      string   `json:"id"`
	Name    string   `json:"name"`
	Artists []string `json:"artists,omitempty"`
	Images  []struct {
		URL    string `json:"url"`
		Width  int    `json:"width"`
		Height int    `json:"height"`
	} `json:"images"`
	Type string `json:"type"`
}

SpotifySearchResult represents a simplified search result

type SpotifyTrackExport added in v0.1.30

type SpotifyTrackExport struct {
	Title      string `json:"title"`
	Artist     string `json:"artist,omitempty"`
	SpotifyID  string `json:"spotify_id,omitempty"`
	Popularity int    `json:"popularity,omitempty"`
}

type StatsResponse

type StatsResponse struct {
	ListenCount     int64 `json:"listen_count"`
	TrackCount      int64 `json:"track_count"`
	AlbumCount      int64 `json:"album_count"`
	ArtistCount     int64 `json:"artist_count"`
	MinutesListened int64 `json:"minutes_listened"`
}

type TopAlbumRecap

type TopAlbumRecap struct {
	ID        int64  `json:"id"`
	Title     string `json:"title"`
	Artist    string `json:"artist"`
	Image     string `json:"image,omitempty"`
	PlayCount int64  `json:"playCount"`
}

type TopArtistRecap

type TopArtistRecap struct {
	ID        int64  `json:"id"`
	Name      string `json:"name"`
	Image     string `json:"image,omitempty"`
	PlayCount int64  `json:"playCount"`
}

type TopTrackRecap

type TopTrackRecap struct {
	ID        int64  `json:"id"`
	Name      string `json:"name"`
	Artist    string `json:"artist"`
	PlayCount int64  `json:"playCount"`
}

type UserTheme

type UserTheme struct {
	Bg          string `json:"bg"`
	BgSecondary string `json:"bgSecondary"`
	BgTertiary  string `json:"bgTertiary"`
	Fg          string `json:"fg"`
	FgSecondary string `json:"fgSecondary"`
	FgTertiary  string `json:"fgTertiary"`
	Primary     string `json:"primary"`
	PrimaryDim  string `json:"primaryDim"`
	Accent      string `json:"accent"`
	AccentDim   string `json:"accentDim"`
	Error       string `json:"error"`
	Warning     string `json:"warning"`
	Success     string `json:"success"`
	Info        string `json:"info"`
}

UserTheme represents the theme data structure

type YearlyRecapResponse

type YearlyRecapResponse struct {
	Year            int             `json:"year"`
	TotalScrobbles  int64           `json:"totalScrobbles"`
	TotalMinutes    int64           `json:"totalMinutes"`
	UniqueArtists   int64           `json:"uniqueArtists"`
	UniqueAlbums    int64           `json:"uniqueAlbums"`
	UniqueTracks    int64           `json:"uniqueTracks"`
	TopArtist       *TopArtistRecap `json:"topArtist"`
	TopAlbum        *TopAlbumRecap  `json:"topAlbum"`
	TopTrack        *TopTrackRecap  `json:"topTrack"`
	TopGenres       []string        `json:"topGenres"`
	MostActiveMonth string          `json:"mostActiveMonth"`
}

Jump to

Keyboard shortcuts

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