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");
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<string>} 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,
};
};