Repository navigation
fix: route song update, delete, lyrics, cover, versions and report endpoints - #851
Merged
Merged
Conversation
|
@zane1502 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Routes the song handlers that already existed but were never reachable: update/delete, lyrics, cover art, version history and content reports. Update and delete are made safe to route (field allow-list, ownership checks, storage cleanup).
Changes
PATCH /api/song/:idandDELETE /api/song/:id(authArtistMiddleware). NewUpdateSongDTOallow-lists title, description, genreId, composers, lyrics, language (validateDTOstrips everything else, and the service only copies those fields). Ownership (owner or admin) is enforced inSongService, returning 403. For a minted song, changing title, description or genreId (the fields in the on-chain metadata) returns 409. Search index andCacheService.clearSongare refreshed.songs/<id>/hls/) and S3-hosted cover art are deleted from S3 (best-effort, errors are logged). A minted or pending song is hidden instead (flagged, removed from search and streaming), since the on-chain token still exists; the response hasdata.hidden. There is no waveform asset in the codebase, so none is deleted. Cleanup runs inline rather than through a queue.GET /api/song/:id/lyrics(public).SongService.getLyricsnow returns 404 unlesslyricsRightsConfirmedAtis set.PUT /api/song/:id/cover(owner only, multipart fieldcover, JPG/PNG, 5 MB, same filter and limit as the existing cover upload; the existing magic-byte check inCoverArtServicestill applies) andGET /api/song/:id/cover(returns the original and thumbnail URLs). Replacing a cover regenerates thumbnails (existing behavior), deletes the previous cover from S3 if it lived there, and clears the song cache. For a minted song only the off-chain cover changes; the image in the on-chain metadata is immutable (documented in OpenAPI and code).GET /api/song/:id/versions(paginated,page/limit) andGET /api/song/:id/versions/:version, restricted to the owning artist and admins (403 otherwise) via a newSongVersionService.assertCanViewHistory.POST /api/song/:id/reportwithrequireAuth,validateDTO(ReportSongDTO)and a new per-user limit of 10 reports per hour (429). A duplicate report returns 409 (existingReportServicebehavior, documented). Reports are stored as pending and are listed by the existingGET /api/admin/reports.docs/openapi.yaml.src/__tests__/SongRoutes.test.ts(ownership, protected fields, minted conflict, S3 deletion with a mocked S3 client, lyrics gating, cover type/size/ownership, versions access and pagination, report duplicate/rate limit/admin queue); updatedSongVersionService.test.tsandCoverArtService.test.ts.Notes and limits:
src/validators/ImageFile.tsprovides class-validator decorators for DTO fields, which do not apply to a multer upload, so the route reuses the existing multer JPG/PNG filter and size limit instead.PATCHare not served until rights are confirmed.:version), matching the existing controller and service.Issues
Resolves #817
Resolves #816
Resolves #815
Resolves #813
Verification
git status; only relevant files are staged, no snapshots or generated files.cargo buildandcargo testwere not run (TypeScript repository).npx jest src/__tests__/SongRoutes.test.ts src/__tests__/CoverArtService.test.ts src/services/__tests__/SongVersionService.test.ts src/__tests__/SongService.test.ts --forceExit: 55 passed, 2 failed. The 2 failures are inCoverArtService.test.ts("pins the original and three thumbnails" and "accepts png and webp uploads"); they fail identically on unmodifiedmainbecause the fixture buffer is not a valid image under the existing magic-byte check.npx tsc --noEmitreports no errors in the touched files (filtered to them).