v3: added an "in collections" section to dump pages, listing the collections a dump belongs to

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
khannurien
2026-08-08 11:41:36 +00:00
parent b84fcdd523
commit a9b94c0bfb
8 changed files with 183 additions and 52 deletions

View File

@@ -8,6 +8,7 @@ import {
isCreateUrlDumpRequest,
isUpdateDumpRequest,
type PaginatedData,
type Playlist,
} from "../model/interfaces.ts";
import { authMiddleware } from "../middleware/auth.ts";
@@ -30,6 +31,7 @@ import {
} from "../services/dump-service.ts";
import { getDumpVoters } from "../services/vote-service.ts";
import { getRelatedDumps } from "../services/backlink-service.ts";
import { getPlaylistsForDump } from "../services/playlist-service.ts";
const router = new Router({ prefix: "/api/dumps" });
@@ -128,6 +130,18 @@ router.get("/:dumpId/related", async (ctx) => {
ctx.response.body = responseBody;
});
router.get("/:dumpId/playlists", async (ctx) => {
const requestingUserId = await parseOptionalAuth(ctx) ?? undefined;
// Resolve through getDump so private dumps 404 for anyone but their owner.
const dump = getDump(ctx.params.dumpId, requestingUserId);
const playlists = getPlaylistsForDump(dump.id, requestingUserId);
const responseBody: APIResponse<Playlist[]> = {
success: true,
data: playlists,
};
ctx.response.body = responseBody;
});
router.get("/", async (ctx) => {
const requestingUserId = await parseOptionalAuth(ctx) ?? undefined;
const { page, limit } = parsePagination(ctx.request.url.searchParams);