| Age | Commit message (Collapse) | Author |
|
|
|
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.
|
|
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.
|
|
|
|
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.
|
|
- 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.
|
|
|
|
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
|
|
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.
|
|
violation
|
|
|
|
filters, permission scoping)
|
|
- 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.
|
|
- 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
|
|
- 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.
|
|
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.
|
|
- 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 .
|
|
|
|
|
|
|
|
|
|
|