diff --git a/libs/notification.js b/libs/notification.js
index 73cb66db..b7aa4b37 100644
--- a/libs/notification.js
+++ b/libs/notification.js
@@ -1,5 +1,6 @@
var fs = require("fs")
var Discord = require("discord.js")
+var template = require("./notifications/emailTemplate.js")
module.exports = function(s,config,lang){
//discord bot
if(config.discordBot === true){
@@ -298,18 +299,30 @@ module.exports = function(s,config,lang){
delete(s.group[d.ke].activeMonitors[d.id].detector_mail);
},detector_mail_timeout);
var files = []
- var mailOptions = {
- from: config.mail.from, // sender address
- to: r.mail, // list of receivers
- subject: lang.Event+' - '+d.screenshotName, // Subject line
- html: ''+lang.EventText1+' '+d.currentTimestamp+'.',
- attachments: files
- }
var sendMail = function(){
- Object.keys(d.details).forEach(function(v,n){
- mailOptions.html+='
'+v+' : '+d.details[v]+'
'
+ const infoRows = []
+ Object.keys(d.details).forEach(function(key){
+ var value = d.details[key]
+ var text = value
+ if(value instanceof Object){
+ text = JSON.stringify(value,null,3)
+ }
+ infoRows.push(template.createRow({
+ title: key,
+ text: text
+ }))
})
- s.nodemailer.sendMail(mailOptions, (error, info) => {
+ s.nodemailer.sendMail({
+ from: config.mail.from,
+ to: r.mail,
+ subject: lang.Event+' - '+d.screenshotName,
+ html: template.createFramework({
+ title: lang.EventText1 + ' ' + d.currentTimestamp,
+ subtitle: 'Shinobi Event',
+ body: infoRows.join(''),
+ }),
+ attachments: files
+ }, (error, info) => {
if (error) {
s.systemLog(lang.MailError,error)
return false;
diff --git a/libs/notifications/emailTemplate.js b/libs/notifications/emailTemplate.js
new file mode 100644
index 00000000..dd18d892
--- /dev/null
+++ b/libs/notifications/emailTemplate.js
@@ -0,0 +1,250 @@
+// Example of how to generate HTML for an email.
+// createFramework({
+// title: 'Password Reset',
+// subtitle: 'If you did not make this request please change your password.',
+// body: [
+// createRow({
+// title: 'Customer',
+// text: `${customer.email} — ${customer.id}`
+// }),
+// createRow({
+// btn: {
+// text: 'Confirm Password Reset',
+// href: `https://licenses.shinobi.video/forgot/reset?code=${newCode}`
+// }
+// }),
+// createRow({
+// title: 'Reset Code',
+// text: newCode
+// }),
+// ].join(''),
+// })
+module.exports = {
+ createRow : (options) => {
+ const trFillers = `
+ |
+
+ |
+
+
+ |
+
+ |
+
`
+ if(options.btn){
+ return `
+
+
+
+
+ |
+
+ |
+
+
+ |
+
+ |
+
+
+ |
+
+
+ |
+
+ ${trFillers}
+
+
+ |
+
`
+ }
+ return `
+
+
+
+
+ |
+
+ |
+
+
+ |
+
+ |
+
+
+
+
+ |
+ ${options.title}
+ |
+
+
+
+
+
+
+
+ |
+ ${options.text}
+ |
+
+
+
+ |
+
+
+ |
+
+ ${trFillers}
+
+
+ |
+
`
+ },
+ createFramework : (options) => {
+ return `
+
+
+
+ |
+
+ |
+
+ ${options.title}
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+
+
+
+
+
+ |
+
+ |
+ ${options.subtitle} |
+
+
+ |
+
+
+ |
+
+ |
+
+
+
+
+
+
+ |
+
+ |
+
+
+ |
+
+ |
+
+
+
+ ${options.body}
+
+ |
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+ |
+
+
+ |
+
+ |
+
+
+
+
+
+
+ |
+
+ |
+
+
+ |
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+
+
+ ${options.footerText ? `
+
+
+ |
+
+ |
+
+ ${options.footerText}
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+
+
` : ''}
+
`
+ }
+}