Fixed Automatische alarmierung nach validierung #45

This commit is contained in:
PxlLoewe
2025-07-06 14:06:44 -07:00
parent 9b954e4053
commit 7682f191c7
5 changed files with 109 additions and 125 deletions

View File

@@ -9,7 +9,7 @@ export const sendAlert = async (
}: {
stationId?: number;
},
user: User,
user: User | "HPG",
): Promise<{
connectedAircrafts: ConnectedAircraft[];
mission: Mission;
@@ -89,23 +89,38 @@ export const sendAlert = async (
.catch((err) => {
// Ignore if the entry already exists
});
await prisma.mission.update({
where: { id: Number(id) },
data: {
state: "running",
missionLog: {
push: {
type: "alert-log",
auto: false,
timeStamp: new Date().toISOString(),
data: {
stationId: stationId,
user: getPublicUser(user, { ignorePrivacy: true }),
},
} as any,
if (user === "HPG") {
await prisma.mission.update({
where: { id: Number(id) },
data: {
state: "running",
missionLog: {
push: {
type: "alert-log",
auto: true,
timeStamp: new Date().toISOString(),
} as any,
},
},
},
});
});
} else {
await prisma.mission.update({
where: { id: Number(id) },
data: {
state: "running",
missionLog: {
push: {
type: "alert-log",
auto: false,
timeStamp: new Date().toISOString(),
data: {
stationId: stationId,
user: getPublicUser(user, { ignorePrivacy: true }),
},
} as any,
},
},
});
}
return { connectedAircrafts, mission };
};