fix: normalize overseer webhook statuses

This commit is contained in:
2026-04-22 14:10:03 -04:00
parent 2a7b4f46b3
commit a5dd85f5c1
+14 -3
View File
@@ -133,11 +133,22 @@ router.post(
router.post(
"/webhook",
asyncHandler(async (req, res) => {
const { request_id, status } = req.body;
if (!request_id || !status)
const rawId =
req.body.request_id ??
req.body.requestId ??
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" });
const request = await prisma.contentRequest.findFirst({
where: { overseerRequestId: request_id },
where: { overseerRequestId: Number(rawId) },
include: { user: true },
});
if (!request) return res.status(404).json({ error: "Request not found" });