From a5dd85f5c10e92394876080e84c409bda35408bf Mon Sep 17 00:00:00 2001 From: hobokenchicken Date: Wed, 22 Apr 2026 14:10:03 -0400 Subject: [PATCH] fix: normalize overseer webhook statuses --- backend/src/routes/overseer.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/src/routes/overseer.ts b/backend/src/routes/overseer.ts index ec290e5..82ce998 100644 --- a/backend/src/routes/overseer.ts +++ b/backend/src/routes/overseer.ts @@ -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" });