fixed #105
This commit is contained in:
@@ -14,6 +14,7 @@ export const sendAlert = async (
|
||||
connectedAircrafts: ConnectedAircraft[];
|
||||
mission: Mission;
|
||||
}> => {
|
||||
try {
|
||||
const mission = await prisma.mission.findUnique({
|
||||
where: { id: id },
|
||||
});
|
||||
@@ -123,4 +124,8 @@ export const sendAlert = async (
|
||||
});
|
||||
}
|
||||
return { connectedAircrafts, mission };
|
||||
} catch (error) {
|
||||
console.error("Error sending mission alert:", error);
|
||||
throw new Error("Ein Fehler ist aufgetreten. Bitte melde den Fehler als Bug");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -50,10 +50,7 @@ const getRthCallsigns = (mission: Mission, stations: Station[]) => {
|
||||
return `🚁 RTH${callsigns.length > 1 ? "s" : ""}: ${callsigns.join(" / ")} `;
|
||||
};
|
||||
|
||||
const getNtfyHeader = (
|
||||
mission: Mission,
|
||||
clientStation: Station,
|
||||
): NtfyHeader => ({
|
||||
const getNtfyHeader = (mission: Mission, clientStation: Station): NtfyHeader => ({
|
||||
headers: {
|
||||
Title: `${clientStation.bosCallsignShort} / ${mission.missionKeywordAbbreviation} / ${mission.missionKeywordCategory}`,
|
||||
Tags: "pager",
|
||||
@@ -76,9 +73,13 @@ export const sendNtfyMission = async (
|
||||
clientStation: Station,
|
||||
ntfyRoom: string,
|
||||
) => {
|
||||
axios.post(
|
||||
try {
|
||||
await axios.post(
|
||||
`https://ntfy.sh/${ntfyRoom}`,
|
||||
getNtfyData(mission, stations),
|
||||
getNtfyHeader(mission, clientStation),
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error sending Ntfy mission:", error);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -189,7 +189,11 @@ router.post("/:id/send-alert", async (req, res) => {
|
||||
return;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).json({ error: "Failed to send mission" });
|
||||
res
|
||||
.status(500)
|
||||
.json({
|
||||
error: `Ein Fehler ist aufgetreten. Bitte melde den Fehler als Bug (${(error as Error).message})`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user