Do thing to fix thing

This commit is contained in:
Christopher Cookman 2024-09-04 08:15:52 -06:00
parent f69cc9c451
commit 5e7a0576e5
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -29,6 +29,7 @@ app.put('/api/connect/:jobid', (req, res) => {
ws_[id].connection.on('close', function() { ws_[id].connection.on('close', function() {
if (ws_[id]) { if (ws_[id]) {
ws_[id].connection.terminate(); ws_[id].connection.terminate();
delete ws_[id];
} }
}) })
ws_[id].open = false; ws_[id].open = false;
@ -44,6 +45,13 @@ app.put('/api/connect/:jobid', (req, res) => {
}); });
app.post("/api/send/:jobid/:id/", (req, res) => { app.post("/api/send/:jobid/:id/", (req, res) => {
if (!ws_[req.params.id]) {
res.status(404).send({
success: false,
message: "Invalid ID"
});
return;
}
if (ws_[req.params.id].jobid !== req.params.jobid) { if (ws_[req.params.id].jobid !== req.params.jobid) {
res.status(401).send({ res.status(401).send({
success: false, success: false,
@ -76,6 +84,13 @@ app.post("/api/send/:jobid/:id/", (req, res) => {
}) })
app.get("/api/poll/:jobid/:id", (req, res) => { app.get("/api/poll/:jobid/:id", (req, res) => {
if (!ws_[req.params.id]) {
res.status(404).send({
success: false,
message: "Invalid ID"
});
return;
}
if (ws_[req.params.id].jobid !== req.params.jobid) { if (ws_[req.params.id].jobid !== req.params.jobid) {
res.status(401).send({ res.status(401).send({
success: false, success: false,