Einsatz geschlossen event wird richtig an piloten gesendet

This commit is contained in:
PxlLoewe
2025-10-28 02:19:55 +01:00
parent da9b957fcf
commit 4d43e2a36d
4 changed files with 27 additions and 5 deletions

View File

@@ -88,7 +88,16 @@ router.patch("/:id", async (req, res) => {
});
io.to("dispatchers").emit("update-mission", { updatedMission });
if (req.body.state === "finished") {
updatedMission.missionStationUserIds?.forEach((userId) => {
const missionUsers = await prisma.missionOnStationUsers.findMany({
where: {
missionId: updatedMission.id,
},
select: {
userId: true,
},
});
console.log("Notifying users about mission closure:", missionUsers);
missionUsers?.forEach(({ userId }) => {
io.to(`user:${userId}`).emit("notification", {
type: "mission-closed",
status: "closed",