Merge remote-tracking branch 'upstream/develop' into feat/60-min-chart

This commit is contained in:
Daniel Cojocea
2024-08-14 15:28:18 -04:00
27 changed files with 451 additions and 423 deletions
+29 -34
View File
@@ -85,43 +85,38 @@ CheckSchema.pre("save", async function (next) {
});
// Check if there are any notifications
if (notifications && notifications.length > 0) {
// Only send email if monitor status has changed
if (monitor.status !== this.status) {
const emailService = new EmailService();
if (monitor.status === true && this.status === false) {
// Notify users that the monitor is down
for (const notification of notifications) {
if (notification.type === "email") {
await emailService.buildAndSendEmail(
"serverIsDownTemplate",
{ monitorName: monitor.name, monitorUrl: monitor.url },
notification.address,
`Monitor ${monitor.name} is down`
);
}
}
}
// Only send email if monitor status has changed
if (monitor.status !== this.status) {
const emailService = new EmailService();
if (monitor.status === false && this.status === true) {
// Notify users that the monitor is up
for (const notification of notifications) {
if (notification.type === "email") {
await emailService.buildAndSendEmail(
"serverIsUpTemplate",
{ monitorName: monitor.name, monitorUrl: monitor.url },
notification.address,
`Monitor ${monitor.name} is back up`
);
}
}
}
// Update monitor status
monitor.status = this.status;
await monitor.save();
let template = "";
let status = "";
if (monitor.status === true && this.status === false) {
template = "serverIsDownTemplate";
status = "down";
}
if (monitor.status === false && this.status === true) {
// Notify users that the monitor is up
template = "serverIsUpTemplate";
status = "up";
}
for (const notification of notifications) {
if (notification.type === "email") {
await emailService.buildAndSendEmail(
template,
{ monitorName: monitor.name, monitorUrl: monitor.url },
notification.address,
`Monitor ${monitor.name} is ${status}`
);
}
}
// Update monitor status
monitor.status = this.status;
await monitor.save();
}
}
} catch (error) {
+3 -4
View File
@@ -984,10 +984,9 @@
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/axios": {
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.3.tgz",
"integrity": "sha512-Ar7ND9pU99eJ9GpoGQKhKf58GpUOgnzuaB7ueNQ5BMi0p+LZ5oaEnfF999fAArcTIBwXTCHAmGcHOZJaWPq9Nw==",
"license": "MIT",
"version": "1.7.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz",
"integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",