Actualizar server.js

This commit is contained in:
2026-03-16 22:23:14 +00:00
parent 9f9bc27060
commit e39b6bd7a9

View File

@@ -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, "");