everydaytok commited on
Commit
6f54930
·
verified ·
1 Parent(s): 9dd75de

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +14 -13
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
- const { secret, jobId, intervalMs, webhookUrl, payload, initialDelay } = req.body;
88
-
89
- if (secret !== CRON_SECRET) return res.status(403).json({ error: "Unauthorized" });
90
-
91
- // 1. Save to DB (Persistence)
92
- const { error } = await supabase.from('system_jobs').upsert({
93
- id: jobId,
94
- interval_ms: intervalMs,
95
- webhook_url: webhookUrl,
96
- payload: payload,
97
- updated_at: new Date()
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