From 5b546417304f03e5219cb41eea8bbfb54d41b1d8 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sat, 26 Apr 2025 22:50:43 +0200 Subject: [PATCH] revert another unintentional change --- server/notification.js | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/server/notification.js b/server/notification.js index 090894bc6..af19dd841 100644 --- a/server/notification.js +++ b/server/notification.js @@ -75,6 +75,7 @@ const YZJ = require("./notification-providers/yzj"); const SMSPlanet = require("./notification-providers/sms-planet"); class Notification { + providerList = {}; /** @@ -164,7 +165,7 @@ class Notification { new SMSPlanet(), ]; for (let item of list) { - if (!item.name) { + if (! item.name) { throw new Error("Notification provider without name"); } @@ -184,19 +185,9 @@ class Notification { * @returns {Promise} Successful msg * @throws Error with fail msg */ - static async send( - notification, - msg, - monitorJSON = null, - heartbeatJSON = null - ) { + static async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { if (this.providerList[notification.type]) { - return this.providerList[notification.type].send( - notification, - msg, - monitorJSON, - heartbeatJSON - ); + return this.providerList[notification.type].send(notification, msg, monitorJSON, heartbeatJSON); } else { throw new Error("Notification type is not supported"); } @@ -218,9 +209,10 @@ class Notification { userID, ]); - if (!bean) { + if (! bean) { throw new Error("notification not found"); } + } else { bean = R.dispense("notification"); } @@ -250,7 +242,7 @@ class Notification { userID, ]); - if (!bean) { + if (! bean) { throw new Error("notification not found"); } @@ -266,6 +258,7 @@ class Notification { let exists = commandExistsSync("apprise"); return exists; } + } /** @@ -276,17 +269,16 @@ class Notification { */ async function applyNotificationEveryMonitor(notificationID, userID) { let monitors = await R.getAll("SELECT id FROM monitor WHERE user_id = ?", [ - userID, + userID ]); for (let i = 0; i < monitors.length; i++) { - let checkNotification = await R.findOne( - "monitor_notification", - " monitor_id = ? AND notification_id = ? ", - [ monitors[i].id, notificationID ] - ); + let checkNotification = await R.findOne("monitor_notification", " monitor_id = ? AND notification_id = ? ", [ + monitors[i].id, + notificationID, + ]); - if (!checkNotification) { + if (! checkNotification) { let relation = R.dispense("monitor_notification"); relation.monitor_id = monitors[i].id; relation.notification_id = notificationID; @@ -297,4 +289,4 @@ async function applyNotificationEveryMonitor(notificationID, userID) { module.exports = { Notification, -}; +}; \ No newline at end of file