summaryrefslogtreecommitdiff
path: root/internal/service/media_test.go
AgeCommit message (Collapse)Author
2026-05-17Restructure repo: move Go server into player-server/Paul Buetow
2026-05-09Refine media browsing and set coversPaul Buetow
2026-05-07j1 fix admin media lifecycle QA defectsPaul Buetow
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 3: decouple API layer from repository with MediaQueryFilter and ↵Paul Buetow
AuthService abstraction
2026-05-03Fix media info and detached playback statePaul Buetow
2026-05-02fix detached playback and scan progressPaul Buetow
2026-05-02more on thisPaul Buetow
2026-05-01Rename Go module from codeberg.org/snonux/play to codeberg.org/snonux/playerPaul Buetow
2026-04-30pa: raise aggregate test coverage to 81.5%Paul Buetow
2026-04-30Wire playback resume end to end (task ka)Paul Buetow
- Add JSON tags to model structs so API responses use camelCase keys (e.g., id, file_name, position_seconds). - MediaDetail now includes progress; add ResumeFrom() helper on MediaDetail. - Frontend playSelected() fetches /api/media/:id and reads progress.position_seconds before starting playback, then passes resume position to selectAndPlay(). - player.js selectAndPlay/loadMedia accept resumeFrom parameter instead of reading media.resume_from from list items. - Backend test coverage: handlers_test verifies detail endpoint returns progress position in JSON; media_test verifies GetMediaDetail includes progress and ResumeFrom() value. - Frontend test coverage: added web/js/tests/playback-resume.test.js validating detail JSON shape, resume position computation, and list item contract.
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-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