|
|
@ -92,6 +92,24 @@ class Notification {
|
|
|
|
console.log(error)
|
|
|
|
console.log(error)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return await Notification.discord(notification, msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (notification.type === "signal") {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
let data = {
|
|
|
|
|
|
|
|
"message": msg,
|
|
|
|
|
|
|
|
"number": notification.signalNumber,
|
|
|
|
|
|
|
|
"recipients": notification.signalRecipients.replace(/\s/g, '').split(",")
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
let config = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let res = await axios.post(notification.signalURL, data, config)
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.log(error)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new Error("Notification type is not supported")
|
|
|
|
throw new Error("Notification type is not supported")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -135,20 +153,15 @@ class Notification {
|
|
|
|
|
|
|
|
|
|
|
|
static async smtp(notification, msg) {
|
|
|
|
static async smtp(notification, msg) {
|
|
|
|
|
|
|
|
|
|
|
|
let data = {
|
|
|
|
let transporter = nodemailer.createTransport({
|
|
|
|
host: notification.smtpHost,
|
|
|
|
host: notification.smtpHost,
|
|
|
|
port: notification.smtpPort,
|
|
|
|
port: notification.smtpPort,
|
|
|
|
secure: notification.smtpSecure,
|
|
|
|
secure: notification.smtpSecure,
|
|
|
|
};
|
|
|
|
auth: {
|
|
|
|
|
|
|
|
|
|
|
|
if (notification.smtpUsername) {
|
|
|
|
|
|
|
|
data.auth = {
|
|
|
|
|
|
|
|
user: notification.smtpUsername,
|
|
|
|
user: notification.smtpUsername,
|
|
|
|
pass: notification.smtpPassword,
|
|
|
|
pass: notification.smtpPassword,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
let transporter = nodemailer.createTransport(data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// send mail with defined transport object
|
|
|
|
// send mail with defined transport object
|
|
|
|
let info = await transporter.sendMail({
|
|
|
|
let info = await transporter.sendMail({
|
|
|
@ -160,6 +173,18 @@ class Notification {
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static async discord(notification, msg) {
|
|
|
|
|
|
|
|
const client = new Discord.Client();
|
|
|
|
|
|
|
|
await client.login(notification.discordToken)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const channel = await client.channels.fetch(notification.discordChannelID);
|
|
|
|
|
|
|
|
await channel.send(msg);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client.destroy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
module.exports = {
|
|
|
|