fix: overseer status coercion

This commit is contained in:
2026-04-22 14:11:02 -04:00
parent a5dd85f5c1
commit 5a8eb90c38
+7 -9
View File
@@ -139,14 +139,12 @@ router.post(
req.body.id ??
req.body.overseer_request_id;
const statusRaw = String(req.body.status || "").toUpperCase();
const status =
statusRaw === "APPROVED" || statusRaw === "COMPLETED"
? "APPROVED"
: statusRaw === "DECLINED" || statusRaw === "FAILED"
? "DECLINED"
: statusRaw;
if (!rawId || !status)
return res.status(400).json({ error: "Missing fields" });
let status = "PENDING";
if (statusRaw === "APPROVED" || statusRaw === "COMPLETED")
status = "APPROVED";
else if (statusRaw === "DECLINED" || statusRaw === "FAILED")
status = "DECLINED";
if (!rawId) return res.status(400).json({ error: "Missing fields" });
const request = await prisma.contentRequest.findFirst({
where: { overseerRequestId: Number(rawId) },
include: { user: true },
@@ -154,7 +152,7 @@ router.post(
if (!request) return res.status(404).json({ error: "Request not found" });
const updatedRequest = await prisma.contentRequest.update({
where: { id: request.id },
data: { status },
data: { status: status as any },
});
if (status === "DECLINED") {
await prisma.transaction.create({