mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-01 11:22:34 +02:00
update notification messages.
This commit is contained in:
parent
b76d48ec94
commit
2e2c510988
1 changed files with 19 additions and 11 deletions
|
@ -890,7 +890,7 @@ class Monitor extends BeanModel {
|
||||||
|
|
||||||
if (Monitor.isImportantForNotification(isFirstBeat, previousBeat?.status, bean.status)) {
|
if (Monitor.isImportantForNotification(isFirstBeat, previousBeat?.status, bean.status)) {
|
||||||
log.debug("monitor", `[${this.name}] sendNotification`);
|
log.debug("monitor", `[${this.name}] sendNotification`);
|
||||||
await Monitor.sendNotification(isFirstBeat, this, bean);
|
await Monitor.sendNotification(isFirstBeat, this, previousBeat, bean);
|
||||||
} else {
|
} else {
|
||||||
log.debug("monitor", `[${this.name}] will not sendNotification because it is (or was) under maintenance`);
|
log.debug("monitor", `[${this.name}] will not sendNotification because it is (or was) under maintenance`);
|
||||||
}
|
}
|
||||||
|
@ -912,7 +912,7 @@ class Monitor extends BeanModel {
|
||||||
if (bean.downCount >= this.resendInterval) {
|
if (bean.downCount >= this.resendInterval) {
|
||||||
// Send notification again, because we are still DOWN
|
// Send notification again, because we are still DOWN
|
||||||
log.debug("monitor", `[${this.name}] sendNotification again: Down Count: ${bean.downCount} | Resend Interval: ${this.resendInterval}`);
|
log.debug("monitor", `[${this.name}] sendNotification again: Down Count: ${bean.downCount} | Resend Interval: ${this.resendInterval}`);
|
||||||
await Monitor.sendNotification(isFirstBeat, this, bean);
|
await Monitor.sendNotification(isFirstBeat, this, previousBeat, bean);
|
||||||
|
|
||||||
// Reset down count
|
// Reset down count
|
||||||
bean.downCount = 0;
|
bean.downCount = 0;
|
||||||
|
@ -1283,24 +1283,32 @@ class Monitor extends BeanModel {
|
||||||
* @param {Bean} bean Status information about monitor
|
* @param {Bean} bean Status information about monitor
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
static async sendNotification(isFirstBeat, monitor, bean) {
|
static async sendNotification(isFirstBeat, monitor, previousbean, actualbean) {
|
||||||
if (!isFirstBeat || bean.status === DOWN) {
|
if (!isFirstBeat || actualbean.status === DOWN) {
|
||||||
const notificationList = await Monitor.getNotificationList(monitor);
|
const notificationList = await Monitor.getNotificationList(monitor);
|
||||||
|
|
||||||
let text;
|
let text;
|
||||||
if (bean.status === UP) {
|
if (actualbean.status === UP) {
|
||||||
text = "✅ Up";
|
if(previousbean.status === MAINTENANCE){
|
||||||
} else if (bean.status === DOWN) {
|
text = "✅ Up After Maintenance";
|
||||||
text = "🔴 Down";
|
} else {
|
||||||
} else if (bean.status === MAINTENANCE) {
|
text = "✅ Up";
|
||||||
|
}
|
||||||
|
} else if (actualbean.status === DOWN) {
|
||||||
|
if(previousbean.status === MAINTENANCE){
|
||||||
|
text = "🔴 Down After Maintenance";
|
||||||
|
} else {
|
||||||
|
text = "🔴 Down";
|
||||||
|
}
|
||||||
|
} else if (actualbean.status === MAINTENANCE) {
|
||||||
text = "🔵 In Maintenance";
|
text = "🔵 In Maintenance";
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg = `[${monitor.name}] [${text}] ${bean.msg}`;
|
let msg = `[${monitor.name}] [${text}] ${actualbean.msg}`;
|
||||||
|
|
||||||
for (let notification of notificationList) {
|
for (let notification of notificationList) {
|
||||||
try {
|
try {
|
||||||
const heartbeatJSON = bean.toJSON();
|
const heartbeatJSON = actualbean.toJSON();
|
||||||
const monitorData = [{ id: monitor.id,
|
const monitorData = [{ id: monitor.id,
|
||||||
active: monitor.active,
|
active: monitor.active,
|
||||||
name: monitor.name
|
name: monitor.name
|
||||||
|
|
Loading…
Add table
Reference in a new issue