mission closed socket event
This commit is contained in:
@@ -87,6 +87,20 @@ router.patch("/:id", async (req, res) => {
|
||||
data: req.body,
|
||||
});
|
||||
io.to("dispatchers").emit("update-mission", { updatedMission });
|
||||
if (req.body.state === "finished") {
|
||||
updatedMission.missionStationUserIds?.forEach((userId) => {
|
||||
io.to(`user:${userId}`).emit("notification", {
|
||||
type: "mission-closed",
|
||||
status: "closed",
|
||||
message: `Einsatz ${updatedMission.publicId} wurde beendet`,
|
||||
data: {
|
||||
missionId: updatedMission.id,
|
||||
publicMissionId: updatedMission.publicId,
|
||||
},
|
||||
} as NotificationPayload);
|
||||
});
|
||||
}
|
||||
|
||||
res.json(updatedMission);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
Reference in New Issue
Block a user