Files
EpicNext-Cms/src/actions/import-badges.ts
T
SimoandCursor 0e89d03940
Local Build and Deploy / deploy (push) Successful in 56s
Finish fine-grained ACL across remaining admin pages and actions.
Replace leftover requireStaff gates with module PERMS, drop hardcoded room rank thresholds, and expand contract tests so admin mutations cannot regress to dashboard-only checks.

Co-authored-by: Cursor <[email protected]>
2026-07-15 20:15:22 +02:00

38 lines
782 B
TypeScript

"use server";
import { requirePermission } from "@/lib/admin/guard";
import { PERMS } from "@/lib/permissions";
import { prisma } from "@/lib/prisma";
export async function importBadgeFromRemote({
code,
name,
description,
}: {
code: string;
name: string;
description: string;
}) {
await requirePermission(PERMS.ASSETS_IMPORT);
try {
await prisma.websiteBadges.upsert({
where: { badgeKey: code },
update: {
badgeName: name,
badgeDescription: description,
updatedAt: new Date(),
},
create: {
badgeKey: code,
badgeName: name,
badgeDescription: description,
createdAt: new Date(),
updatedAt: new Date(),
},
});
return { ok: true as const };
} catch {
return { ok: false as const, error: "Failed to import badge" };
}
}