mission closed socket event
This commit is contained in:
@@ -87,6 +87,20 @@ router.patch("/:id", async (req, res) => {
|
|||||||
data: req.body,
|
data: req.body,
|
||||||
});
|
});
|
||||||
io.to("dispatchers").emit("update-mission", { updatedMission });
|
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);
|
res.json(updatedMission);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -50,9 +50,20 @@ export type MissionAutoClose = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type MissionClosed = {
|
||||||
|
type: "mission-closed";
|
||||||
|
status: "closed";
|
||||||
|
message: string;
|
||||||
|
data: {
|
||||||
|
missionId: number;
|
||||||
|
publicMissionId: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export type NotificationPayload =
|
export type NotificationPayload =
|
||||||
| ValidationFailed
|
| ValidationFailed
|
||||||
| ValidationSuccess
|
| ValidationSuccess
|
||||||
| AdminMessage
|
| AdminMessage
|
||||||
| StationStatus
|
| StationStatus
|
||||||
| MissionAutoClose;
|
| MissionAutoClose
|
||||||
|
| MissionClosed;
|
||||||
|
|||||||
Reference in New Issue
Block a user