1
0
mirror of https://github.com/louislam/uptime-kuma.git synced 2025-11-25 22:41:57 +02:00

fix: child monitors disappear after group deletion (#6287)

Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
This commit is contained in:
Dorian Grasset
2025-11-03 21:21:36 +01:00
committed by GitHub
parent a52186cf7e
commit 5207ba6d97

View File

@@ -1060,6 +1060,27 @@ let needSetup = false;
const startTime = Date.now();
// Check if this is a group monitor and unlink children before deletion
const monitor = await R.findOne("monitor", " id = ? AND user_id = ? ", [
monitorID,
socket.userID,
]);
if (monitor && monitor.type === "group") {
// Get all children before unlinking them
const children = await Monitor.getChildren(monitorID);
// Unlink all children from the group
await Monitor.unlinkAllChildren(monitorID);
// Notify frontend to update each child monitor's parent to null
if (children && children.length > 0) {
for (const child of children) {
await server.sendUpdateMonitorIntoList(socket, child.id);
}
}
}
await R.exec("DELETE FROM monitor WHERE id = ? AND user_id = ? ", [
monitorID,
socket.userID,