fac9b96cca
CI / build (push) Has been cancelled
Folders were an implementation detail leaking into the event workflow: every upload needed a folder first and photos were split across pages. Uploads now land in a single implicit "Photos" folder and the event page renders one gallery with the uploader and an edited-only download. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { NextRequest } from "next/server";
|
|
import { gateSession } from "@/auth/api";
|
|
import { getEventFolderAccess } from "@/db/events";
|
|
import { errorResponse } from "@/lib/http";
|
|
import { uploadEventPhoto } from "@/lib/event-photo-upload";
|
|
|
|
/**
|
|
* POST /api/events/:id/folders/:folderId/photos?name=IMG_0001.CR3
|
|
*
|
|
* Folder-scoped upload kept for direct API use. The event page posts to
|
|
* `/api/events/:id/photos`, which picks the event's one implicit folder.
|
|
*/
|
|
export const POST = async (
|
|
req: NextRequest,
|
|
{ params }: { params: Promise<{ id: string; folderId: string }> },
|
|
) => {
|
|
const gate = await gateSession();
|
|
if (gate instanceof Response) return gate;
|
|
|
|
const { id, folderId } = await params;
|
|
const access = await getEventFolderAccess(folderId, gate.id, gate.systemRole);
|
|
if (!access || access.eventId !== id) {
|
|
return errorResponse(404, "unknown folder");
|
|
}
|
|
if (!access.canContribute) {
|
|
return errorResponse(403, "you are not assigned to this event");
|
|
}
|
|
|
|
return uploadEventPhoto(req, {
|
|
eventId: id,
|
|
folderId,
|
|
uploaderId: gate.id,
|
|
});
|
|
};
|