everydaycats commited on
Commit
c21e868
·
verified ·
1 Parent(s): bf511d0

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +5 -5
app.js CHANGED
@@ -428,12 +428,12 @@ app.post('/project/feedback', async (req, res) => {
428
  app.post('/project/ping', async (req, res) => {
429
  // 1. Accept userId along with projectId
430
  const { projectId, userId } = req.body;
431
- console.log("1");
432
 
433
  if (!projectId || !userId) {
434
  return res.status(400).json({ error: "Missing ID fields" });
435
  }
436
- console.log("2");
437
  // 2. Retrieve Project State (Hydrates from DB if not in memory)
438
  const project = await StateManager.getProject(projectId);
439
 
@@ -442,14 +442,14 @@ console.log("2");
442
  console.log("project not found in db, id: ", projectId);
443
  return res.status(404).json({ action: "IDLE", error: "Project not found" });
444
  }
445
- console.log("3");
446
 
447
  // 3. SECURITY CHECK: Ensure the user matches the project owner
448
  if (project.userId !== userId) {
449
  console.warn(`[Security] Unauthorized ping for ${projectId}. Owner: ${project.userId}, Request: ${userId}`);
450
  return res.status(403).json({ error: "Unauthorized: You do not own this project." });
451
  }
452
- console.log("4");
453
  // 4. Retrieve Command (Only if authorized)
454
  const command = await StateManager.popCommand(projectId);
455
 
@@ -464,7 +464,7 @@ console.log("4");
464
  });
465
  }
466
  } else {
467
- console.log("5");
468
  res.json({ action: "IDLE" });
469
  }
470
  });
 
428
  app.post('/project/ping', async (req, res) => {
429
  // 1. Accept userId along with projectId
430
  const { projectId, userId } = req.body;
431
+ // console.log("1");
432
 
433
  if (!projectId || !userId) {
434
  return res.status(400).json({ error: "Missing ID fields" });
435
  }
436
+ // console.log("2");
437
  // 2. Retrieve Project State (Hydrates from DB if not in memory)
438
  const project = await StateManager.getProject(projectId);
439
 
 
442
  console.log("project not found in db, id: ", projectId);
443
  return res.status(404).json({ action: "IDLE", error: "Project not found" });
444
  }
445
+ // console.log("3");
446
 
447
  // 3. SECURITY CHECK: Ensure the user matches the project owner
448
  if (project.userId !== userId) {
449
  console.warn(`[Security] Unauthorized ping for ${projectId}. Owner: ${project.userId}, Request: ${userId}`);
450
  return res.status(403).json({ error: "Unauthorized: You do not own this project." });
451
  }
452
+ // console.log("4");
453
  // 4. Retrieve Command (Only if authorized)
454
  const command = await StateManager.popCommand(projectId);
455
 
 
464
  });
465
  }
466
  } else {
467
+ // console.log("5");
468
  res.json({ action: "IDLE" });
469
  }
470
  });