do not send notification if first beat is UP
This commit is contained in:
parent
072e86542a
commit
ff4259380e
server/model
|
@ -109,27 +109,30 @@ class Monitor extends BeanModel {
|
||||||
if (! previousBeat || previousBeat.status !== bean.status) {
|
if (! previousBeat || previousBeat.status !== bean.status) {
|
||||||
bean.important = true;
|
bean.important = true;
|
||||||
|
|
||||||
let notificationList = await R.getAll(`SELECT notification.* FROM notification, monitor_notification WHERE monitor_id = ? AND monitor_notification.notification_id = notification.id `, [
|
// Do not send if first beat is UP
|
||||||
this.id
|
if (previousBeat || bean.status !== 1) {
|
||||||
])
|
let notificationList = await R.getAll(`SELECT notification.* FROM notification, monitor_notification WHERE monitor_id = ? AND monitor_notification.notification_id = notification.id `, [
|
||||||
|
this.id
|
||||||
|
])
|
||||||
|
|
||||||
let promiseList = [];
|
let promiseList = [];
|
||||||
|
|
||||||
let text;
|
let text;
|
||||||
if (bean.status === 1) {
|
if (bean.status === 1) {
|
||||||
text = "✅ Up"
|
text = "✅ Up"
|
||||||
} else {
|
} else {
|
||||||
text = "🔴 Down"
|
text = "🔴 Down"
|
||||||
|
}
|
||||||
|
|
||||||
|
let msg = `[${this.name}] [${text}] ${bean.msg}`;
|
||||||
|
|
||||||
|
for(let notification of notificationList) {
|
||||||
|
promiseList.push(Notification.send(JSON.parse(notification.config), msg, await this.toJSON(), bean.toJSON()));
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all(promiseList);
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg = `[${this.name}] [${text}] ${bean.msg}`;
|
|
||||||
|
|
||||||
for(let notification of notificationList) {
|
|
||||||
promiseList.push(Notification.send(JSON.parse(notification.config), msg, await this.toJSON(), bean.toJSON()));
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(promiseList);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
bean.important = false;
|
bean.important = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue