Local Build and Deploy / deploy (push) Successful in 56s
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]>
38 lines
782 B
TypeScript
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" };
|
|
}
|
|
}
|