begin proper secton for Notification toggles

- Future versions may have breaking changes involving notifications. Currently each type of notification has a toggle for each method. It will be mad so that a Method is the toggle for all types of Notifications and each type of Notifications will have a single toggle. This will be to mitigate the speed of the ever-growing numer of options.
fix-non-showing-inputs
Moe Alam 2020-09-30 19:39:14 -07:00
parent f8e5235b1f
commit 14b15be4c0
3 changed files with 125 additions and 48 deletions

View File

@ -3922,6 +3922,76 @@ module.exports = function(s,config,lang){
},
],
},
"Notifications": {
"name": lang['Notifications'],
"color": "blue",
isAdvanced: true,
"isSection": true,
"id": "monSectionNotifications",
"selector": "h_det",
"attribute": `triggerChange="#add_monitor [detail=detector_record_method]"`,
"blockquote": `${lang.DetectorText}\n<p class="shinobi-detector-msg"></p>`,
"info": [
{
"name": lang.Methods,
"color": "blue",
isFormGroupGroup: true,
"info": [
{
"name": "detail=notify_email",
"field": lang.Email,
"default": "0",
"example": "",
"fieldType": "select",
"possible": [
{
"name": lang.No,
"value": "0"
},
{
"name": lang.Yes,
"value": "1"
}
]
},
{
"name": "detail=notify_discord",
"field": lang.Discord,
"default": "0",
"example": "",
"fieldType": "select",
"possible": [
{
"name": lang.No,
"value": "0"
},
{
"name": lang.Yes,
"value": "1"
}
]
},
],
},
{
"name": "detail=notify_onUnexpectedExit",
"field": lang['On Unexpected Exit'],
"default": "0",
"example": "1",
"fieldType": "select",
"possible": [
{
"name": lang.No,
"value": "0"
},
{
"name": lang.Yes,
"value": "1"
}
]
},
]
},
"Logging": {
"name": lang.Logging,
"color": "green",

View File

@ -199,6 +199,9 @@
"Start Time": "Start Time",
"End Time": "End Time",
"Time": "Time",
"On Unexpected Exit": "On Unexpected Exit",
"Methods": "Methods",
"Notifications": "Notifications",
"Monitor ID": "Monitor ID",
"File Type": "File Type",
"Filesize": "Filesize",

View File

@ -193,23 +193,25 @@ module.exports = function(s,config,lang){
}
}
const onMonitorUnexpectedExitForDiscord = (monitorConfig) => {
const ffmpegCommand = s.group[monitorConfig.ke].activeMonitors[monitorConfig.mid].ffmpeg
const description = lang['Process Crashed for Monitor'] + '\n' + ffmpegCommand
const currentTime = new Date()
s.discordMsg({
author: {
name: monitorConfig.name + ' : ' + monitorConfig.mid,
icon_url: config.iconURL
},
title: lang['Process Unexpected Exit'] + ' : ' + monitorConfig.name,
description: description,
fields: [],
timestamp: currentTime,
footer: {
icon_url: config.iconURL,
text: "Shinobi Systems"
}
},[],monitorConfig.ke)
if(monitorConfig.details.notify_discord === '1' && monitorConfig.details.notify_onUnexpectedExit === '1'){
const ffmpegCommand = s.group[monitorConfig.ke].activeMonitors[monitorConfig.mid].ffmpeg
const description = lang['Process Crashed for Monitor'] + '\n' + ffmpegCommand
const currentTime = new Date()
s.discordMsg({
author: {
name: monitorConfig.name + ' : ' + monitorConfig.mid,
icon_url: config.iconURL
},
title: lang['Process Unexpected Exit'] + ' : ' + monitorConfig.name,
description: description,
fields: [],
timestamp: currentTime,
footer: {
icon_url: config.iconURL,
text: "Shinobi Systems"
}
},[],monitorConfig.ke)
}
}
s.loadGroupAppExtender(loadDiscordBotForUser)
s.unloadGroupAppExtender(unloadDiscordBotForUser)
@ -410,38 +412,40 @@ module.exports = function(s,config,lang){
}
}
const onMonitorUnexpectedExitForEmail = (monitorConfig) => {
const ffmpegCommand = s.group[monitorConfig.ke].activeMonitors[monitorConfig.mid].ffmpeg
const description = ffmpegCommand
const subject = lang['Process Unexpected Exit'] + ' : ' + monitorConfig.name
const currentTime = new Date()
s.knexQuery({
action: "select",
columns: "mail",
table: "Users",
where: [
['ke','=',monitorConfig.ke],
['details','NOT LIKE','%"sub"%'],
]
},(err,r) => {
r = r[0]
s.nodemailer.sendMail({
from: config.mail.from,
to: checkEmail(r.mail),
subject: subject,
html: template.createFramework({
title: subject,
subtitle: lang['Process Crashed for Monitor'],
body: description,
footerText: currentTime
}),
attachments: []
}, (error, info) => {
if (error) {
s.systemLog(lang.MailError,error)
return false;
}
if(monitorConfig.details.notify_email === '1' && monitorConfig.details.notify_onUnexpectedExit === '1'){
const ffmpegCommand = s.group[monitorConfig.ke].activeMonitors[monitorConfig.mid].ffmpeg
const description = ffmpegCommand
const subject = lang['Process Unexpected Exit'] + ' : ' + monitorConfig.name
const currentTime = new Date()
s.knexQuery({
action: "select",
columns: "mail",
table: "Users",
where: [
['ke','=',monitorConfig.ke],
['details','NOT LIKE','%"sub"%'],
]
},(err,r) => {
r = r[0]
s.nodemailer.sendMail({
from: config.mail.from,
to: checkEmail(r.mail),
subject: subject,
html: template.createFramework({
title: subject,
subtitle: lang['Process Crashed for Monitor'],
body: description,
footerText: currentTime
}),
attachments: []
}, (error, info) => {
if (error) {
s.systemLog(lang.MailError,error)
return false;
}
})
})
})
}
}
s.onTwoFactorAuthCodeNotification(onTwoFactorAuthCodeNotificationForEmail)
s.onEventTriggerBeforeFilter(onEventTriggerBeforeFilterForEmail)