-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add support for IFTTT, Mailgun (SMTP) and Matrix.
- Loading branch information
Paul Aschmann
committed
Jul 21, 2022
1 parent
38d3ac9
commit 2e30d70
Showing
5 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
const provider = require("./provider"); | ||
const axios = require("axios"); | ||
|
||
class Ifttt extends provider { | ||
|
||
name = "ifttt"; | ||
|
||
parameters = { | ||
required: { | ||
iftttServiceKey: "", | ||
eventName: "", | ||
text: "" | ||
}, | ||
optional: {} | ||
}; | ||
|
||
async send(notification) { | ||
try { | ||
let data = { | ||
"text": notification.required.text, | ||
}; | ||
let config = {}; | ||
|
||
let iftttUrl = "https://maker.ifttt.com/trigger/" + notification.required.eventName + "/json/with/key/" + notification.required.iftttServiceKey; | ||
|
||
await axios.post(iftttUrl, data, config); | ||
|
||
return "Sent Successfully."; | ||
} catch (err) { | ||
return err; | ||
} | ||
} | ||
} | ||
|
||
module.exports = Ifttt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const provider = require("./provider"); | ||
const nodemailer = require('nodemailer'); | ||
|
||
class MailGun extends provider { | ||
|
||
name = "mailgun"; | ||
|
||
parameters = { | ||
required: { | ||
smtpUsername: "", | ||
smtpPassword: "", | ||
smtpFrom: "", | ||
smtpTo: "", | ||
subject : "", | ||
text: "" | ||
}, | ||
optional: { | ||
smtpCC: "", | ||
smtpBCC: "", | ||
html: "", | ||
attachments: "" | ||
} | ||
}; | ||
|
||
async send(notification) { | ||
try { | ||
const config = { | ||
host: "smtp.mailgun.org", | ||
port: "587", | ||
secure: false, | ||
tls: { | ||
rejectUnauthorized: false, | ||
}, | ||
auth: { | ||
user: notification.required.smtpUsername, | ||
pass: notification.required.smtpPassword, | ||
} | ||
}; | ||
|
||
let transporter = nodemailer.createTransport(config); | ||
|
||
await transporter.sendMail({ | ||
from: notification.required.smtpFrom, | ||
cc: notification.optional.smtpCC, | ||
bcc: notification.optional.smtpBCC, | ||
to: notification.required.smtpTo, | ||
subject: notification.required.subject, | ||
text: notification.required.text, | ||
html: notification.optional.html, | ||
attachments: notification.optional.attachments | ||
}); | ||
|
||
return "Message Sent"; | ||
} catch (err) { | ||
return err; | ||
} | ||
} | ||
} | ||
|
||
module.exports = MailGun; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const provider = require("./provider"); | ||
const axios = require("axios"); | ||
|
||
class Matrix extends provider { | ||
|
||
name = "matrix"; | ||
|
||
parameters = { | ||
required: { | ||
matrixHomeServerUrl: "", | ||
matrixAccessToken: "", | ||
matrixRoomId: "", | ||
text: "" | ||
}, | ||
optional: {} | ||
}; | ||
|
||
async send(notification) { | ||
try { | ||
let serverUrl = notification.required.matrixHomeServerUrl + "/_matrix/client/r0/rooms/" + notification.required.matrixRoomId + "/send/m.room.message?access_token=" + notification.required.matrixAccessToken; | ||
let config = { | ||
headers: { | ||
"Content-Type": "application/json" | ||
} | ||
}; | ||
let data = { | ||
"msgtype": "m.text", | ||
"body": notification.required.text | ||
}; | ||
|
||
|
||
await axios.post(serverUrl, data, config); | ||
|
||
return "Sent Successfully."; | ||
} catch (err) { | ||
return err; | ||
} | ||
} | ||
} | ||
|
||
module.exports = Matrix; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters