Made sure that async uages have the appropreate await

pull/4574/head
Frank Elsinga 2 months ago
parent a0c62d8ab0
commit bf411c4a13

@ -189,9 +189,9 @@ class Maintenance extends BeanModel {
/** /**
* Throw error if cron is invalid * Throw error if cron is invalid
* @param {string|Date} cron Pattern or date * @param {string|Date} cron Pattern or date
* @returns {Promise<void>} * @returns {void}
*/ */
static async validateCron(cron) { static validateCron(cron) {
let job = new Cron(cron, () => {}); let job = new Cron(cron, () => {});
job.stop(); job.stop();
} }

@ -947,7 +947,7 @@ class Monitor extends BeanModel {
log.debug("monitor", `[${this.name}] apicache clear`); log.debug("monitor", `[${this.name}] apicache clear`);
apicache.clear(); apicache.clear();
UptimeKumaServer.getInstance().sendMaintenanceListByUserID(this.user_id); await UptimeKumaServer.getInstance().sendMaintenanceListByUserID(this.user_id);
} else { } else {
bean.important = false; bean.important = false;
@ -1377,7 +1377,7 @@ class Monitor extends BeanModel {
let notifyDays = await setting("tlsExpiryNotifyDays"); let notifyDays = await setting("tlsExpiryNotifyDays");
if (notifyDays == null || !Array.isArray(notifyDays)) { if (notifyDays == null || !Array.isArray(notifyDays)) {
// Reset Default // Reset Default
setSetting("tlsExpiryNotifyDays", [ 7, 14, 21 ], "general"); await setSetting("tlsExpiryNotifyDays", [ 7, 14, 21 ], "general");
notifyDays = [ 7, 14, 21 ]; notifyDays = [ 7, 14, 21 ];
} }

@ -21,7 +21,7 @@ class DingDing extends NotificationProvider {
text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`, 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; return okMsg;
} }
} else { } else {
@ -31,7 +31,7 @@ class DingDing extends NotificationProvider {
content: msg content: msg
} }
}; };
if (this.sendToDingDing(notification, params)) { if (await this.sendToDingDing(notification, params)) {
return okMsg; return okMsg;
} }
} }

@ -294,7 +294,7 @@ let needSetup = false;
log.debug("server", "Adding socket handler"); log.debug("server", "Adding socket handler");
io.on("connection", async (socket) => { io.on("connection", async (socket) => {
sendInfo(socket, true); await sendInfo(socket, true);
if (needSetup) { if (needSetup) {
log.info("server", "Redirect to setup page"); log.info("server", "Redirect to setup page");
@ -326,7 +326,7 @@ let needSetup = false;
} }
log.debug("auth", "afterLogin"); log.debug("auth", "afterLogin");
afterLogin(socket, user); await afterLogin(socket, user);
log.debug("auth", "afterLogin ok"); log.debug("auth", "afterLogin ok");
log.info("auth", `Successfully logged in user ${decoded.username}. IP=${clientIP}`); log.info("auth", `Successfully logged in user ${decoded.username}. IP=${clientIP}`);
@ -382,7 +382,7 @@ let needSetup = false;
if (user) { if (user) {
if (user.twofa_status === 0) { if (user.twofa_status === 0) {
afterLogin(socket, user); await afterLogin(socket, user);
log.info("auth", `Successfully logged in user ${data.username}. IP=${clientIP}`); 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); let verify = notp.totp.verify(data.token, user.twofa_secret, twoFAVerifyOptions);
if (user.twofa_last_token !== data.token && verify) { 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 = ? ", [ await R.exec("UPDATE `user` SET twofa_last_token = ? WHERE id = ? ", [
data.token, data.token,
@ -1351,8 +1351,8 @@ let needSetup = false;
msgi18n: true, msgi18n: true,
}); });
sendInfo(socket); await sendInfo(socket);
server.sendMaintenanceList(socket); await server.sendMaintenanceList(socket);
} catch (e) { } catch (e) {
callback({ callback({
@ -1532,7 +1532,7 @@ let needSetup = false;
log.debug("auth", "check auto login"); log.debug("auth", "check auto login");
if (await setting("disableAuth")) { if (await setting("disableAuth")) {
log.info("auth", "Disabled Auth: auto login to admin"); 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"); socket.emit("autoLogin");
} else { } else {
log.debug("auth", "need auth"); log.debug("auth", "need auth");
@ -1548,7 +1548,7 @@ let needSetup = false;
process.exit(1); process.exit(1);
}); });
server.start(); await server.start();
server.httpServer.listen(port, hostname, () => { server.httpServer.listen(port, hostname, () => {
if (hostname) { if (hostname) {
@ -1619,13 +1619,13 @@ async function afterLogin(socket, user) {
socket.join(user.id); socket.join(user.id);
let monitorList = await server.sendMonitorList(socket); let monitorList = await server.sendMonitorList(socket);
sendInfo(socket); await sendInfo(socket);
server.sendMaintenanceList(socket); await server.sendMaintenanceList(socket);
sendNotificationList(socket); await sendNotificationList(socket);
sendProxyList(socket); await sendProxyList(socket);
sendDockerHostList(socket); await sendDockerHostList(socket);
sendAPIKeyList(socket); await sendAPIKeyList(socket);
sendRemoteBrowserList(socket); await sendRemoteBrowserList(socket);
await sleep(500); await sleep(500);

@ -27,7 +27,7 @@ module.exports = (socket) => {
socket.on("shrinkDatabase", async (callback) => { socket.on("shrinkDatabase", async (callback) => {
try { try {
checkLogin(socket); checkLogin(socket);
Database.shrink(); await Database.shrink();
callback({ callback({
ok: true, ok: true,
}); });

@ -1535,7 +1535,7 @@ message HealthCheckResponse {
// Start the new parent monitor after edit is done // Start the new parent monitor after edit is done
if (createdNewParent) { if (createdNewParent) {
this.startParentGroupMonitor(); await this.startParentGroupMonitor();
} }
this.processing = false; this.processing = false;
this.$root.getMonitorList(); this.$root.getMonitorList();

Loading…
Cancel
Save