This commit is contained in:
@@ -282,8 +282,20 @@ router.post("/:id/hpg-validation-result", async (req, res) => {
|
||||
|
||||
router.post("/:id/validate-hpg", async (req, res) => {
|
||||
try {
|
||||
const config = await prisma.config.findFirst({
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
});
|
||||
if (config?.disableHPG) {
|
||||
res.status(400).json({
|
||||
error: "HPG is disabled",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const { id } = req.params;
|
||||
const config = req.body as
|
||||
const body = req.body as
|
||||
| {
|
||||
alertWhenValid?: boolean;
|
||||
}
|
||||
@@ -336,7 +348,7 @@ router.post("/:id/validate-hpg", async (req, res) => {
|
||||
io.to(`desktop:${activeAircraftinMission?.userId}`).emit("hpg-validation", {
|
||||
missionId: parseInt(id),
|
||||
userId: req.user?.id,
|
||||
alertWhenValid: config?.alertWhenValid || false,
|
||||
alertWhenValid: body?.alertWhenValid || false,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
Reference in New Issue
Block a user