summaryrefslogtreecommitdiff
path: root/internal/service/media.go
AgeCommit message (Collapse)Author
2026-05-17Restructure repo: move Go server into player-server/Paul Buetow
2026-05-10refactor(service,scanner): return concrete types from constructorsPaul Buetow
Apply the Go best-practice convention 'accept interfaces, return concrete types' across the service and scanner packages: - NewBrowseService -> *browseService - NewWriteService -> *writeService - NewMediaStreamer -> *mediaStreamer - NewFSScanner -> *FSScanner - NewFSScannerWithLogger -> *FSScanner - NewPodcastBrowseService -> *podcastBrowseService - NewTagService -> *tagService - NewShareService -> *shareService - NewProgressService -> *progressService - NewAdminService -> *adminService - NewAdminServiceWithLogger -> *adminService - NewAuthService -> *authService - NewNoteService -> *noteService - NewFavService -> *favService - NewMediaService -> *mediaService - NewMediaServiceWithPodcastBrowser -> *mediaService Callers continue to work unchanged because Go allows assigning a concrete type to an interface variable. All tests pass with -race -cover.
2026-05-10Decouple podcast browse logic from BrowseSet via PodcastBrowser interfacePaul Buetow
Extract PodcastBrowser interface and podcastBrowseService implementation to move podcast-specific grid augmentation out of browseService.BrowseSet. - Remove PodcastRepo from BrowseServiceStore and MediaServiceStore. - browseService now delegates podcast set augmentation to an injected PodcastBrowser strategy (kept optional/nil-safe). - Add NewMediaServiceWithPodcastBrowser to wire a real PodcastBrowser (backed by PodcastRepo) in production while keeping the plain NewMediaService for existing callers/tests. - Update main.go to instantiate NewPodcastBrowseService and inject it. - Update browse_test.go to test PodcastBrowser-augmented paths through the new constructor signature. This keeps BrowseSet focused on files and folders only and removes the podcast dependency from the browse contract.
2026-05-07Task 21: move thumbnail regeneration to write servicePaul Buetow
2026-05-03task 2: decompose mediaService and adminService into role-focused structsPaul Buetow
Extract accessHelper and split mediaService into: - browseService (read-only browsing, streaming, thumbnails) - writeService (upload, soft-delete, restore) - shareService (share links) - tagService (tagging) - favService (favorites) - noteService (notes) Split adminService into: - trashService (list deleted media) - scanService (trigger rescan, scan progress) - userAdminService (create/list/delete users) - permissionAdminService (grant/revoke/list permissions) Add repository sub-interfaces for each service. Add negative tests for share sub-service.
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-02fix:xPaul 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-01service: split media.go (745 lines) into 5 focused filesPaul Buetow
Split the monolithic media.go into cohesive files to fix KISS/SRP violation: - media_access.go: permission verification helpers (verifyAccess, verifyModifyAccess, verifySetModifyAccess) - media_browse.go: browsing, listing, streaming, thumbnails, set cover, tags and favorites - media_write.go: upload, create, soft-delete, restore - media_share.go: share token creation, validation, revocation, streaming via token - media_notes.go: note get/upsert/delete The shared mediaService struct, NewMediaService constructor, and common helpers (supported extensions, type guessing, thumbnail generation) remain in media.go. No functional changes — all tests pass.
2026-05-01Split MediaService interface into role-specific interfaces to fix ISP/OCP ↵Paul Buetow
violation
2026-05-01Rename Go module from codeberg.org/snonux/play to codeberg.org/snonux/playerPaul Buetow
2026-04-30task ia: fix media listing/filtering semantics (favorites bool, filesize ↵Paul Buetow
filters, permission scoping)
2026-04-30task ha: enforce upload limits, role checks, probing, thumbnails, cleanupPaul Buetow
- handlers.go: enforce MAX_UPLOAD_SIZE_MB via http.MaxBytesReader and http.MaxBytesError mapping to 413. - service/media.go: UploadMedia now verifies owner/admin, rejects unsupported extensions, probes metadata with ffprobe, generates video thumbnails, enforces unique filenames, and cleans up temp files + hard-deletes DB row on any failure. - Reconcile PLAN.md 500MB -> 100MB default to match AGENTS.md/config. - Add service and API tests for max-size rejection, unsupported extension, missing role, probe failure, thumbnail failure, cleanup, and success paths.
2026-04-30ga — implement thumbnail and set cover regeneration end to endPaul Buetow
- mediaService: implement RegenerateThumbnail and RegenerateSetCover - Inject thumb.Generator and probe.Prober into MediaService - Update NewMediaService constructor and all call sites - Add service tests for success, failure, permission denied, and not-found - Add API tests for cover regeneration and thumbnail error mapping - All tests pass
2026-04-30ja: implement public share landing page and improve error mappingPaul Buetow
- Add web/share.html with a minimal HTML5 video player, theme variables, centered layout, play overlay, and Back to Home link. - Update handleSharePage to return HTML for browser Accept headers (text/html or empty) and JSON for application/json. Return 410 Gone for expired shares. - Update handleShareStream to map service errors to distinct HTTP codes: ErrShareExpired -> 410, ErrShareNotFound/ErrMediaNotFound -> 404. - Improve ValidateShareToken and StreamSharedMedia to return sentinel errors (ErrShareNotFound, ErrShareExpired, ErrMediaNotFound) instead of generic string errors. - Update and add tests for share page HTML/JSON negotiation and share stream 404/410 responses.
2026-04-30task da: enforce media access and owner/admin role permissionsPaul Buetow
Changes: - MediaService.ListMedia now accepts userID and filters by allowed sets for non-admins via AllowedSetIDs in repository.MediaFilter. - Handlers pass userID into ListMedia; API returns 403 for forbidden. - Added verifyModifyAccess and verifySetModifyAccess helpers so only owners/admins can upload, soft-delete, restore, and regenerate thumbnails/covers; viewers are blocked. - GetMediaDetail, ToggleFavorite, AssignTag, RemoveTag, notes, and shares now consistently verifyAccess before proceeding. - Handlers handle ErrForbidden with 403 for soft-delete and restore. - Added negative tests proving viewers cannot mutate and unauthorized users cannot access/detail/tag/note/favorite/share inaccessible media.
2026-04-30Rename module to codeberg.org/snonux/play (task aa)Paul Buetow
- Update go.mod module path - Replace all internal imports from github.com/paul/kiss-media-player to codeberg.org/snonux/play - Run go mod tidy and gofmt -w .
2026-04-30refactor: use filepath.Join + filepath.Clean for filesystem pathsPaul Buetow
2026-04-30refactor: split repository.Store into focused interfacesPaul Buetow
2026-04-30fix: add explicit permission checks to StreamMedia and DownloadMediaPaul Buetow
2026-04-29fix: prevent path traversal in UploadMediaPaul Buetow
2026-04-29feat(n9): Implement MediaService, AdminService, ProgressService, GCWorkerPaul Buetow