feat: implement hard delete, email notifications, watermark, and fix bulk download

This commit is contained in:
Leon Tonhäuser committed 2026-08-11 12:28:39 +02:00
1 parent 8dd1e10fea
commit 4667615ed0
15 files changed
+369 -65

No files matched your search

@@ -5,6 +5,10 @@ import { headers } from "next/headers";
import { AlbumGrantError, albumGrantService } from "@/modules/albums/grants";
import { requireAdmin } from "@/modules/auth/principal";
import { emailService } from "@/modules/email/service";
import { db } from "@/db/client";
import { editorialAccounts } from "@/db/schema";
import { eq } from "drizzle-orm";
// Returned to the client form so failures surface as inline German text
// instead of an opaque Next.js error-digest page (a thrown server action
@@ -55,6 +59,37 @@ export async function revokeAlbumAction(
return INITIAL_RESULT;
}
export async function sendAlbumNotificationAction(
editorialId: string,
_prevState: AlbumActionResult,
formData: FormData,
): Promise<AlbumActionResult> {
await getAdminPrincipal();
const safeEditorialId = requiredId(editorialId);
const albumName = formData.get("albumName");
if (typeof albumName !== "string" || !albumName) {
return { ok: false, message: "Ungültiger Albumname." };
}
try {
const [editorial] = await db
.select({ loginEmail: editorialAccounts.loginEmail })
.from(editorialAccounts)
.where(eq(editorialAccounts.id, safeEditorialId));
if (!editorial) {
return { ok: false, message: "Redaktion nicht gefunden." };
}
await emailService.sendNewAlbumNotification(editorial.loginEmail, albumName);
return { ok: true, message: "Benachrichtigung erfolgreich gesendet." };
} catch (error) {
console.error("Failed to send album notification:", error);
return { ok: false, message: "E-Mail konnte nicht gesendet werden." };
}
}
async function getAdminPrincipal() {
return requireAdmin(new Headers(await headers()));
}