Spaces:
Paused
Paused
Update app.js
Browse files
app.js
CHANGED
|
@@ -84,19 +84,20 @@ function startJobInternal(jobId, intervalMs, url, payload, initialDelay = 0) {
|
|
| 84 |
app.get('/', (req, res) => res.send('Cron Registry Active'));
|
| 85 |
|
| 86 |
app.post('/register', async (req, res) => {
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
|
|
|
| 100 |
if (error) return res.status(500).json({ error: error.message });
|
| 101 |
|
| 102 |
// 2. Start in Memory
|
|
|
|
| 84 |
app.get('/', (req, res) => res.send('Cron Registry Active'));
|
| 85 |
|
| 86 |
app.post('/register', async (req, res) => {
|
| 87 |
+
const { secret, jobId, intervalMs, webhookUrl, payload, initialDelay, leadId } = req.body;
|
| 88 |
+
|
| 89 |
+
if (secret !== CRON_SECRET) return res.status(403).json({ error: "Unauthorized" });
|
| 90 |
+
|
| 91 |
+
// Save to DB (Now including lead_id)
|
| 92 |
+
const { error } = await supabase.from('system_jobs').upsert({
|
| 93 |
+
id: jobId,
|
| 94 |
+
lead_id: leadId, // <--- Save the UUID here
|
| 95 |
+
interval_ms: intervalMs,
|
| 96 |
+
webhook_url: webhookUrl,
|
| 97 |
+
payload: payload,
|
| 98 |
+
updated_at: new Date()
|
| 99 |
+
});
|
| 100 |
+
|
| 101 |
if (error) return res.status(500).json({ error: error.message });
|
| 102 |
|
| 103 |
// 2. Start in Memory
|