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
* @param {string|Date} cron Pattern or date
* @returns {Promise<void>}
* @returns {void}
*/
static async validateCron(cron) {
static validateCron(cron) {
let job = new Cron(cron, () => {});
job.stop();
}

@ -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 ];
}

@ -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;
}
}

@ -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);

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

@ -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();

Loading…
Cancel
Save