revert another unintentional change

This commit is contained in:
Frank Elsinga 2025-04-26 22:50:43 +02:00
parent a4ef1471b7
commit 5b54641730

View file

@ -75,6 +75,7 @@ const YZJ = require("./notification-providers/yzj");
const SMSPlanet = require("./notification-providers/sms-planet"); const SMSPlanet = require("./notification-providers/sms-planet");
class Notification { class Notification {
providerList = {}; providerList = {};
/** /**
@ -164,7 +165,7 @@ class Notification {
new SMSPlanet(), new SMSPlanet(),
]; ];
for (let item of list) { for (let item of list) {
if (!item.name) { if (! item.name) {
throw new Error("Notification provider without name"); throw new Error("Notification provider without name");
} }
@ -184,19 +185,9 @@ class Notification {
* @returns {Promise<string>} Successful msg * @returns {Promise<string>} Successful msg
* @throws Error with fail msg * @throws Error with fail msg
*/ */
static async send( static async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
notification,
msg,
monitorJSON = null,
heartbeatJSON = null
) {
if (this.providerList[notification.type]) { if (this.providerList[notification.type]) {
return this.providerList[notification.type].send( return this.providerList[notification.type].send(notification, msg, monitorJSON, heartbeatJSON);
notification,
msg,
monitorJSON,
heartbeatJSON
);
} else { } else {
throw new Error("Notification type is not supported"); throw new Error("Notification type is not supported");
} }
@ -218,9 +209,10 @@ class Notification {
userID, userID,
]); ]);
if (!bean) { if (! bean) {
throw new Error("notification not found"); throw new Error("notification not found");
} }
} else { } else {
bean = R.dispense("notification"); bean = R.dispense("notification");
} }
@ -250,7 +242,7 @@ class Notification {
userID, userID,
]); ]);
if (!bean) { if (! bean) {
throw new Error("notification not found"); throw new Error("notification not found");
} }
@ -266,6 +258,7 @@ class Notification {
let exists = commandExistsSync("apprise"); let exists = commandExistsSync("apprise");
return exists; return exists;
} }
} }
/** /**
@ -276,17 +269,16 @@ class Notification {
*/ */
async function applyNotificationEveryMonitor(notificationID, userID) { async function applyNotificationEveryMonitor(notificationID, userID) {
let monitors = await R.getAll("SELECT id FROM monitor WHERE user_id = ?", [ let monitors = await R.getAll("SELECT id FROM monitor WHERE user_id = ?", [
userID, userID
]); ]);
for (let i = 0; i < monitors.length; i++) { for (let i = 0; i < monitors.length; i++) {
let checkNotification = await R.findOne( let checkNotification = await R.findOne("monitor_notification", " monitor_id = ? AND notification_id = ? ", [
"monitor_notification", monitors[i].id,
" monitor_id = ? AND notification_id = ? ", notificationID,
[ monitors[i].id, notificationID ] ]);
);
if (!checkNotification) { if (! checkNotification) {
let relation = R.dispense("monitor_notification"); let relation = R.dispense("monitor_notification");
relation.monitor_id = monitors[i].id; relation.monitor_id = monitors[i].id;
relation.notification_id = notificationID; relation.notification_id = notificationID;