peppa/apps/web/app/api/feedback/[id]/shots/[n]/route.ts
Асель 2c396ff007 PEP-143: web form, «Обращения» page, Home card, translations, glossary, help
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-16 11:23:09 +05:00

21 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// PEP-143: a screenshot of a report — only its author and the superadmins see it.
import { feedbackScreenshot } from "@peppa/core";
import { currentUser } from "@/lib/auth";
import { db } from "@/lib/db";
import { getT } from "@/lib/i18n";
export const dynamic = "force-dynamic";
export async function GET(_req: Request, { params }: { params: Promise<{ id: string; n: string }> }) {
const user = await currentUser();
const t = await getT();
if (!user) return new Response(t("Нужен вход"), { status: 401 });
const { id, n } = await params;
const shot = /^\d+$/.test(id) && /^\d+$/.test(n) ? await feedbackScreenshot(db, user, Number(id), Number(n)) : null;
// Somebody else's report and a missing one look the same.
if (!shot) return new Response(t("Не найдено"), { status: 404 });
return new Response(new Uint8Array(shot.data), {
headers: { "Content-Type": shot.mime, "Cache-Control": "private, max-age=3600", "X-Content-Type-Options": "nosniff", "Content-Disposition": "inline", "Content-Security-Policy": "default-src 'none'; sandbox" },
});
}