summaryrefslogtreecommitdiff
path: root/internal/api
AgeCommit message (Collapse)Author
2026-05-17Restructure repo: move Go server into player-server/Paul Buetow
2026-05-17Add progress status API routesPaul Buetow
2026-05-17Add playback repository cleanup queriesPaul Buetow
2026-05-10refactor: move ServeHTTP above unexported helpers for public-method orderingPaul Buetow
2026-05-10Move self-deletion guard from handler into AdminService (DeleteUser) to fix ↵Paul Buetow
SoC violation - Add ErrCannotDeleteSelf sentinel error in service layer. - Change DeleteUser signature to (ctx, callerID, id) across all layers. - Move self-deletion guard from handleDeleteUser handler into userAdminService.DeleteUser. - Update handleError to map ErrCannotDeleteSelf to 400 BadRequest. - Adjust all affected tests to use the new signature.
2026-05-10api: reject id==0 in handleDeleteUser to avoid 200 OK for invalid pathPaul Buetow
2026-05-10refactor(api): replace all writeJSON 500 error patterns with handleError helperPaul Buetow
2026-05-10fix(tests): handle json.Unmarshal errors explicitly in *_test.goPaul Buetow
2026-05-10internal/service: fix ListEpisodes global pagination by using cross-feed SQL ↵Paul Buetow
query Previously ListEpisodes requested per-feed episodes with the full limit from every feed, concatenated them, and then sliced the resulting slice in memory. This silently skipped episodes from deeper pages because the per-feed DB limit never returned them. Fix: Add a new repository method ListEpisodesByFeedIDsWithStatus that takes a slice of feed IDs and applies LIMIT/OFFSET globally in a single SQL query (IN (...)). The service builds the feed ID list and delegates pagination to the database instead of emulating it in memory. Files changed: - internal/repository/podcast.go: add ListEpisodesByFeedIDsWithStatus - internal/repository/podcast_repo.go: extend PodcastRepo interface - internal/repository/mock.go: add mock implementation - internal/service/podcast.go: replace per-feed loop with new method - internal/service/podcast_test.go: add tests for ListEpisodes - internal/repository/podcast_test.go: add integration tests for new repo method - internal/api/handlers_test.go: add mockPingStore method
2026-05-10Add circuit breaker / backoff for failing podcast feeds in CheckFeedsPaul Buetow
- DB: add consecutive_failures and next_check_at to podcast_feeds - model: add ConsecutiveFailures and NextCheckAt to PodcastFeed struct - repository: update CRUD queries to handle new columns and ListFeedsNeedingCheck to skip feeds with future next_check_at - service: update CheckFeeds to use new query, update checkFeed to reset counters on success and increment exponential backoff on failure - tests: adapt mock signatures, add backoff integration test
2026-05-09internal/api: panic early in NewServerWithLogger if Config is nilPaul Buetow
Prevents nil dereference panics in handlers that unconditionally access s.cfg (share, media, auth). Fail-fast at wiring time matches project convention.
2026-05-09Extract SessionManager interface to fix DIP violationPaul Buetow
- Introduce auth.SessionManager interface in internal/auth/interfaces.go - Rename concrete struct to sessionManager (unexported) and have it satisfy interface - Update api/service layers to depend on interface, not concrete type - Add MockSessionManager for testing - Update all call sites and tests to use interface
2026-05-09Refine media browsing and set coversPaul Buetow
2026-05-07Fix podcast browser workflows for k1Paul Buetow
2026-05-07i1 omit empty share thumbnail URLPaul Buetow
2026-05-07Fix PWA static routes for browser smoke test g1Paul Buetow
2026-05-07Fix upload multipart memory budget for t0Paul Buetow
2026-05-07Fix static file read seeker guard for s0Paul Buetow
2026-05-07Task 51: add API error helpersPaul Buetow
2026-05-07task 31: introduce media streamer servicePaul Buetow
2026-05-07Task 21: move thumbnail regeneration to write servicePaul Buetow
2026-05-07Refactor API server dependencies for task 11Paul Buetow
2026-05-07Handle share page marshal errors (a1)Paul Buetow
2026-05-06internal/service: inject http.Client into podcastService constructor (task 41)Paul Buetow
2026-05-06Fix music video duration display in progress barPaul Buetow
2026-05-06Add podcast E2E integration testsPaul Buetow
2026-05-05Fix podcast support critical bugs from code reviewPaul Buetow
- Fix boolean scanning from SQLite INTEGER columns (intToBool helper) - Fix BrowseSet LIMIT 0 returning zero episodes (use 1000 instead) - Fix checkFeed double-fetch by parsing from resp.Body directly + Add ParseFeedReader for body reuse - Fix file handle leak in DownloadEpisode (explicit Close before ImportMediaFile) - Fix incomplete rollback in DownloadEpisode (remove file + delete media row) - Fix 204 No Content handler writing 'null' body - Fix DownloadCoverImage to accept *http.Client with timeout - Deduplicate uniqueFilename into shared internal/service/filename.go - Wire frontend renderPodcastEpisodes into renderBrowse from API data - Refactor podcasts.js: remove extra API call, fix toggle toast, remove duplicate toast - Add Config.PodcastCheckMinutes + PODCAST_CHECK_INTERVAL_MINUTES env var - Start background CheckFeeds goroutine in main.go with ticker - Update NewPodcastService to accept checkInterval parameter - Log errors from CheckFeeds and episode creation instead of silently discarding
2026-05-05Add podcast support backend: RSS/Atom feeds, episode management, cover scrapingPaul Buetow
2026-05-04Use white-background PNG logo for README, favicon, and loginPaul Buetow
- Generate logo.png (white bg) from SVG for README and login screen - Regenerate favicon.ico from white-background logo - Keep original logo.svg available for future edits - Update server routes and middleware to serve new logo.png
2026-05-04Add project logo, favicon, and display logo on login screenPaul Buetow
- Add logo.svg at project root and reference it in README.md - Generate favicon.ico from logo and place in web/ - Serve logo.svg and favicon.ico as static assets - Display logo on the login page with responsive sizing
2026-05-04task f: validate media_id and sessionID in progress handler and servicePaul Buetow
2026-05-04task 7: refactor oversized functions into helpersPaul Buetow
Refactored the following functions per CLAUDE.md (50+ line limit): - internal/scanner/scanner.go: scanSet (192 → 56 lines) Extracted: ensureSet, loadExistingMedia, gatherCoverImages, thumbnailForVideo, thumbnailForImage, buildThumbnailPath, processNewFile, updateAudioThumbnails - internal/repository/migrate.go: Migrate (134 → 23 lines) Extracted: enableForeignKeys, execSchema; split schema into tablesSchema and indexesSchema constants - internal/config.go: LoadConfig (85 → 28 lines) Extracted: defaultConfig, loadNumericSettings, loadStringSettings, loadLogLevel, loadSecureCookies; added validLogLevels variable - cmd/mediaplayer/main.go: run / runWithSignal (114 → 26 / 26 lines) Extracted: parseVersionFlag, buildLogger, wireDeps, runServer, ensureSignalChannel, shutdownGracefully; introduced appDeps struct - internal/api/server.go: routes (96 → 8 lines) Extracted per route group: routesPublic, routesSharePublic, routesStatic, routesHTML, routesAuth, routesSets, routesMedia, routesNotes, routesProgress, routesShares, routesAdmin Added helpers: requireSession, requireAdmin, publicMethod - internal/service/browse.go: BrowseSet (85 → 26 lines) Extracted: prefixForParent, classifyMediaPath, buildFolderMap, folderHasCover, buildFolders All public interfaces remain unchanged. Tests pass: go test ./... -race -cover
2026-05-04task 9: Centralize file extension and media type mappings in internal/mediatypePaul Buetow
Create a new internal/mediatype package with a single source of truth for: - Extension-to-media-type mappings (TypeForExt) - Extension-to-MIME mappings (MIMETypeForExt) - Supported extension checks (IsSupportedExt, IsImageExt, IsCoverImageExt) Replace duplicated logic across: - internal/service/service.go (supportedExtensions, guessMediaType) - internal/scanner/scanner.go (mediaExtensions, imageExtensions, mediaTypeFromExt) - internal/api/handlers.go (probe.MimeTypeForFilename) - internal/probe/probe.go (imageExtensions, isImagePath) - internal/probe/remux.go (MimeTypeForFilename) Divergent defaults unified: both scanner and service now default unknown extensions to video (model.MediaTypeVideo) via mediatype.TypeForExt. Update tests to use mediatype package and remove obsolete scanner tests. Update AGENTS.md to reflect the new package.
2026-05-04task c: run gofmt and fix unwrapped error literals across the codebasePaul Buetow
2026-05-04task 3: decouple API layer from repository with MediaQueryFilter and ↵Paul Buetow
AuthService abstraction
2026-05-04task 6: narrow service interfaces in Server and MiddlewarePaul Buetow
Split Server struct to accept narrow service interfaces instead of fat composites (MediaService, AdminService). Each handler now depends only on its specific slice (MediaBrowseService, MediaWriteService, etc.). Split Middleware to depend on a narrow UserStore interface instead of full repository.Store. Updated all constructors, call sites, and tests. Added negative tests for nil AdminService and ProgressService returning 501 Not Implemented. References task 6.
2026-05-03Task 8: standardize scanner and handler loggingPaul Buetow
2026-05-03refactor(api): extract Remuxer interface and move ffmpeg/MPEG-TS/mime logic ↵Paul Buetow
to internal/probe Move LooksLikeMPEGTS, MimeTypeForFilename and the ffmpeg remux path out of the api transport layer into a new internal/probe/remux.go package. This removes os/exec and mime tables from the api layer, satisfying the DIP principle. - New probe.Remuxer interface with FFRemuxer implementation - Server depends on probe.Remuxer, injected via NewServer - Updated cmd/mediaplayer wiring and all test helpers - All tests pass: go test ./... -race -cover
2026-05-03fix(admin): fix rescan goroutine lifecycle and race on shared ScanProgressPaul Buetow
- Protect adminService scan state (cancel func + progress pointer) with sync.Mutex. - Allocate fresh ScanProgress per trigger and pass it to the scanner, eliminating races on the previously shared progress struct. - Cancel previous scan context before starting a new one. - Add tests for cancellation, fresh progress per scan, concurrent triggers, and empty progress when never started. - Fix race-prone tests by polling Running==true before waiting for completion.
2026-05-03feat: hybrid cache-busting for thumbnails and coversPaul Buetow
- Add Cache-Control: no-cache headers to thumbnail and cover endpoints (GET /api/media/{id}/thumbnail, GET /api/sets/{id}/cover, GET /s/{token}/thumbnail) so browsers revalidate instead of serving stale cached images after regeneration. - Add frontend cache-busting via ?t=Date.now() after folder cover regeneration so the browser fetches the newly overwritten image. - Replace toolbar filters with inline search syntax (min:, max:, tag:, like:, type:, sort:, minsize:, maxsize:) for faster filtering. - Remove dedicated toolbar and advanced filter panel; consolidate all filtering into the search bar. - Expand filter state to support filesize_min/filesize_max.
2026-05-02fix detached playback and scan progressPaul Buetow
2026-05-02feat: secure shares with keyboard-first My Shares modal (hotkeys S/L)Paul Buetow
2026-05-02more on thisPaul Buetow
2026-05-02fix:xPaul Buetow
2026-05-01api: remux MPEG-TS files to MP4 on the flyPaul Buetow
2026-05-01Task 1: Create AuthService and route handleBootstrap/handleLogin through itPaul Buetow
Introduce service.AuthService interface with Bootstrap and Login methods, a concrete authService implementation, and a MockAuthService for testing. Wire AuthService into api.Server and update cmd/mediaplayer/main.go to use it. This removes direct store access from handleBootstrap and handleLogin, fixing the DIP violation. Sentinel errors (ErrAlreadyBootstrapped, ErrInvalidCredentials) are added to the service package so the API layer can map them to the correct HTTP status codes without leaking DB details. Files created: - internal/service/auth.go Files modified: - internal/service/service.go - internal/service/media.go - internal/service/mock.go - internal/repository/repository.go - internal/repository/mock.go - internal/api/server.go - internal/api/handlers_auth.go - internal/api/handlers_test.go - internal/api/handlers_more_test.go - cmd/mediaplayer/main.go
2026-05-01refactor(api): split monolithic handlers.go into domain-specific files (task 3)Paul Buetow
Split internal/api/handlers.go (1045 lines) to improve KISS/SRP: - handlers_auth.go – bootstrap, login, logout, health, session cookies - handlers_media.go – sets, media CRUD, tags, favorites, notes, progress - handlers_share.go – create/list/revoke shares, share page, share stream - handlers_admin.go – trash, rescan, users, permissions - handlers_file.go – stream, download, thumbnail, regenerate thumbnail Shared helpers (writeJSON, readJSON, pathID, serveFileResult, mimeTypeForFilename, etc.) remain in handlers.go. All tests pass: go test ./... -race -cover.
2026-05-01Add player stage collapse, multi-set selection, grid nav, m4b support, ↵Paul Buetow
content-type fixes, thumbnail refresh, and verbose logging
2026-05-01add readme and so onPaul Buetow
2026-05-01Add support for audiobook/cover images with ancestor lookup and fix keyboard ↵Paul Buetow
navigation Backend: - Add UpdateMediaThumbnail to MediaRepo for efficient thumbnail-only updates - Update ScannerStore interface to include thumbnail update capability - Update mock implementations across repository and API layers for interface changes - Enhance scanner to detect image files in ancestor directories for audio covers - Add background goroutine for async rescan to avoid HTTP timeout Frontend: - Fix hjkl cursor keys to navigate grid properly - Implement ancestor directory cover image lookup for audiobooks Infrastructure: - Add start.sh helper script for quick server startup during development