Skip to content

Commit

Permalink
fix(status page): Make sure the group deletion is correctly handled w…
Browse files Browse the repository at this point in the history
…hen `groupIDList` is empty (#5340)
  • Loading branch information
Ionys320 authored Nov 12, 2024
1 parent 778363a commit 8a432ac
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions server/socket-handlers/status-page-socket-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,17 @@ module.exports.statusPageSocketHandler = (socket) => {

// Delete groups that are not in the list
log.debug("socket", "Delete groups that are not in the list");
const slots = groupIDList.map(() => "?").join(",");
if (groupIDList.length === 0) {
await R.exec("DELETE FROM `group` WHERE status_page_id = ?", [ statusPage.id ]);
} else {
const slots = groupIDList.map(() => "?").join(",");

const data = [
...groupIDList,
statusPage.id
];
await R.exec(`DELETE FROM \`group\` WHERE id NOT IN (${slots}) AND status_page_id = ?`, data);
const data = [
...groupIDList,
statusPage.id
];
await R.exec(`DELETE FROM \`group\` WHERE id NOT IN (${slots}) AND status_page_id = ?`, data);
}

const server = UptimeKumaServer.getInstance();

Expand Down

0 comments on commit 8a432ac

Please sign in to comment.