mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-07 13:32:35 +02:00
fix(monitor-checks): use helper for saving monitor checks
This commit is contained in:
parent
e1680231aa
commit
1a7b69d4aa
1 changed files with 1 additions and 20 deletions
|
@ -536,26 +536,7 @@ exports.entryPage = "dashboard";
|
||||||
|
|
||||||
await R.store(bean);
|
await R.store(bean);
|
||||||
|
|
||||||
// Store checks
|
await updateMonitorChecks(bean.id, checks);
|
||||||
let trx = await R.begin();
|
|
||||||
try {
|
|
||||||
// delete existing checks for monitor
|
|
||||||
await trx.exec("DELETE FROM `monitor_checks` WHERE monitor_id = ?", [bean.id]);
|
|
||||||
|
|
||||||
// Replace them with new checks
|
|
||||||
for (let i = 0; i < (checks || []).length; i++) {
|
|
||||||
let checkBean = trx.dispense("monitor_checks");
|
|
||||||
checkBean.type = checks[i].type;
|
|
||||||
checkBean.value = typeof checks[i].value === "object" ? JSON.stringify(checks[i].value) : checks[i].value;
|
|
||||||
checkBean.monitor_id = bean.id;
|
|
||||||
await trx.store(checkBean);
|
|
||||||
}
|
|
||||||
await trx.commit();
|
|
||||||
} catch (err) {
|
|
||||||
await trx.rollback();
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
await updateMonitorNotification(bean.id, monitor.notificationIDList);
|
await updateMonitorNotification(bean.id, monitor.notificationIDList);
|
||||||
|
|
||||||
if (bean.active) {
|
if (bean.active) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue