diff --git a/server/model/maintenance.js b/server/model/maintenance.js index fb51060e..c6d7386b 100644 --- a/server/model/maintenance.js +++ b/server/model/maintenance.js @@ -189,9 +189,9 @@ class Maintenance extends BeanModel { /** * Throw error if cron is invalid * @param {string|Date} cron Pattern or date - * @returns {Promise} + * @returns {void} */ - static async validateCron(cron) { + static validateCron(cron) { let job = new Cron(cron, () => {}); job.stop(); } diff --git a/server/model/monitor.js b/server/model/monitor.js index fbed48f9..0bef3b7d 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -947,7 +947,7 @@ class Monitor extends BeanModel { log.debug("monitor", `[${this.name}] apicache clear`); apicache.clear(); - UptimeKumaServer.getInstance().sendMaintenanceListByUserID(this.user_id); + await UptimeKumaServer.getInstance().sendMaintenanceListByUserID(this.user_id); } else { bean.important = false; @@ -1377,7 +1377,7 @@ class Monitor extends BeanModel { let notifyDays = await setting("tlsExpiryNotifyDays"); if (notifyDays == null || !Array.isArray(notifyDays)) { // Reset Default - setSetting("tlsExpiryNotifyDays", [ 7, 14, 21 ], "general"); + await setSetting("tlsExpiryNotifyDays", [ 7, 14, 21 ], "general"); notifyDays = [ 7, 14, 21 ]; } diff --git a/server/notification-providers/dingding.js b/server/notification-providers/dingding.js index be3a2fbc..1f2f9b67 100644 --- a/server/notification-providers/dingding.js +++ b/server/notification-providers/dingding.js @@ -21,7 +21,7 @@ class DingDing extends NotificationProvider { text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`, } }; - if (this.sendToDingDing(notification, params)) { + if (await this.sendToDingDing(notification, params)) { return okMsg; } } else { @@ -31,7 +31,7 @@ class DingDing extends NotificationProvider { content: msg } }; - if (this.sendToDingDing(notification, params)) { + if (await this.sendToDingDing(notification, params)) { return okMsg; } } diff --git a/server/server.js b/server/server.js index eeffb063..b41eb198 100644 --- a/server/server.js +++ b/server/server.js @@ -294,7 +294,7 @@ let needSetup = false; log.debug("server", "Adding socket handler"); io.on("connection", async (socket) => { - sendInfo(socket, true); + await sendInfo(socket, true); if (needSetup) { log.info("server", "Redirect to setup page"); @@ -326,7 +326,7 @@ let needSetup = false; } log.debug("auth", "afterLogin"); - afterLogin(socket, user); + await afterLogin(socket, user); log.debug("auth", "afterLogin ok"); log.info("auth", `Successfully logged in user ${decoded.username}. IP=${clientIP}`); @@ -382,7 +382,7 @@ let needSetup = false; if (user) { if (user.twofa_status === 0) { - afterLogin(socket, user); + await afterLogin(socket, user); log.info("auth", `Successfully logged in user ${data.username}. IP=${clientIP}`); @@ -405,7 +405,7 @@ let needSetup = false; let verify = notp.totp.verify(data.token, user.twofa_secret, twoFAVerifyOptions); if (user.twofa_last_token !== data.token && verify) { - afterLogin(socket, user); + await afterLogin(socket, user); await R.exec("UPDATE `user` SET twofa_last_token = ? WHERE id = ? ", [ data.token, @@ -1351,8 +1351,8 @@ let needSetup = false; msgi18n: true, }); - sendInfo(socket); - server.sendMaintenanceList(socket); + await sendInfo(socket); + await server.sendMaintenanceList(socket); } catch (e) { callback({ @@ -1532,7 +1532,7 @@ let needSetup = false; log.debug("auth", "check auto login"); if (await setting("disableAuth")) { log.info("auth", "Disabled Auth: auto login to admin"); - afterLogin(socket, await R.findOne("user")); + await afterLogin(socket, await R.findOne("user")); socket.emit("autoLogin"); } else { log.debug("auth", "need auth"); @@ -1548,7 +1548,7 @@ let needSetup = false; process.exit(1); }); - server.start(); + await server.start(); server.httpServer.listen(port, hostname, () => { if (hostname) { @@ -1619,13 +1619,13 @@ async function afterLogin(socket, user) { socket.join(user.id); let monitorList = await server.sendMonitorList(socket); - sendInfo(socket); - server.sendMaintenanceList(socket); - sendNotificationList(socket); - sendProxyList(socket); - sendDockerHostList(socket); - sendAPIKeyList(socket); - sendRemoteBrowserList(socket); + await sendInfo(socket); + await server.sendMaintenanceList(socket); + await sendNotificationList(socket); + await sendProxyList(socket); + await sendDockerHostList(socket); + await sendAPIKeyList(socket); + await sendRemoteBrowserList(socket); await sleep(500); diff --git a/server/socket-handlers/database-socket-handler.js b/server/socket-handlers/database-socket-handler.js index 8441520a..bcf34c90 100644 --- a/server/socket-handlers/database-socket-handler.js +++ b/server/socket-handlers/database-socket-handler.js @@ -27,7 +27,7 @@ module.exports = (socket) => { socket.on("shrinkDatabase", async (callback) => { try { checkLogin(socket); - Database.shrink(); + await Database.shrink(); callback({ ok: true, }); diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 72cb181e..b6274764 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -1535,7 +1535,7 @@ message HealthCheckResponse { // Start the new parent monitor after edit is done if (createdNewParent) { - this.startParentGroupMonitor(); + await this.startParentGroupMonitor(); } this.processing = false; this.$root.getMonitorList();