Move title generation to notification class

This commit is contained in:
Domenic Horner
2021-09-04 11:06:06 +08:00
parent 9c32adfb55
commit 6ae279c7f3
3 changed files with 15 additions and 12 deletions

View File

@@ -270,18 +270,9 @@ class Monitor extends BeanModel {
this.id,
])
let text;
if (bean.status === UP) {
text = "✅ Up"
} else {
text = "🔴 Down"
}
let msg = `[${this.name}] [${text}] ${bean.msg}`;
for (let notification of notificationList) {
try {
await Notification.send(JSON.parse(notification.config), msg, await this.toJSON(), bean.toJSON())
await Notification.send(JSON.parse(notification.config), this.name, await this.toJSON(), bean.toJSON())
} catch (e) {
console.error("Cannot send notification to " + notification.name);
console.log(e);