Actualizar server.js
This commit is contained in:
@@ -987,10 +987,11 @@ app.post("/public/new-request", async (req, res) => {
|
||||
try {
|
||||
const { phone, name, address, guild_id, description, is_urgent, owner_id } = req.body;
|
||||
|
||||
if (!phone || !guild_id) return res.status(400).json({ ok: false, error: "Faltan datos clave" });
|
||||
// 🚨 CAMBIO SAAS: Obligamos a que venga el owner_id sí o sí
|
||||
if (!phone || !guild_id || !owner_id) return res.status(400).json({ ok: false, error: "Faltan datos clave de la empresa" });
|
||||
|
||||
// 🛡️ CONVERSIÓN ESTRICTA DE DATOS (Para que PostgreSQL no lance Error 500)
|
||||
const targetOwnerId = parseInt(owner_id) || 1;
|
||||
const targetOwnerId = parseInt(owner_id); // Quitamos el "|| 1" para que no asigne a la Empresa 1 por error
|
||||
const safeGuildId = parseInt(guild_id) || 0;
|
||||
const isUrgentBool = is_urgent === true || is_urgent === 'true';
|
||||
const cleanPhone = String(phone).replace(/\D/g, "");
|
||||
|
||||
Reference in New Issue
Block a user