prevent uploading kills to a match that's closed

This commit is contained in:
2023-08-12 13:55:47 +02:00
parent 74a10f8aea
commit fdbd2d873d
+14 -1
View File
@@ -100,7 +100,7 @@ router.post(
} = req.body;
const match = await db
.selectFrom("ToneAPI_v3.match")
.select(["ToneAPI_v3.match.host_id", "ToneAPI_v3.match.match_id"])
.select(["ToneAPI_v3.match.ongoing", "ToneAPI_v3.match.match_id"])
.where("ToneAPI_v3.match.host_id", "=", host_id)
.where("ToneAPI_v3.match.match_id", "=", match_id)
.executeTakeFirst();
@@ -116,6 +116,19 @@ router.post(
});
return;
}
if(!match.ongoing){
res.status(409).send({
errors: [
{
msg: "Match is already closed",
param: "match_id",
location: "body",
},
],
});
return;
}
let attacker_loadout: number | undefined;
let victim_loadout: number | undefined;
await Promise.all([