Actualizar server.js
This commit is contained in:
12
server.js
12
server.js
@@ -331,12 +331,12 @@ async function ensureInstance(instanceName) {
|
|||||||
app.get("/public/assignment/:token", async (req, res) => {
|
app.get("/public/assignment/:token", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { token } = req.params;
|
const { token } = req.params;
|
||||||
const q = await pool.query(`
|
const q = await pool.query(`
|
||||||
SELECT ap.*, s.raw_data, u.full_name as worker_name
|
SELECT ap.*, s.raw_data, u.full_name as worker_name
|
||||||
FROM assignment_pings ap
|
FROM assignment_pings ap
|
||||||
JOIN scraped_services s ON ap.scraped_id = s.id
|
JOIN scraped_services s ON ap.scraped_id = s.id
|
||||||
JOIN users u ON ap.user_id = u.id
|
JOIN users u ON ap.user_id = u.id
|
||||||
WHERE ap.token = $1 AND ap.status = 'pending' AND ap.expires_at > NOW()
|
WHERE ap.token = $1 AND ap.status = 'pending' AND ap.expires_at > NOW()
|
||||||
`, [token]);
|
`, [token]);
|
||||||
if (q.rowCount === 0) return res.status(404).json({ ok: false, error: "Enlace caducado" });
|
if (q.rowCount === 0) return res.status(404).json({ ok: false, error: "Enlace caducado" });
|
||||||
res.json({ ok: true, service: q.rows[0].raw_data, worker: q.rows[0].worker_name });
|
res.json({ ok: true, service: q.rows[0].raw_data, worker: q.rows[0].worker_name });
|
||||||
|
|||||||
Reference in New Issue
Block a user