diff --git a/definitions/en_CA.js b/definitions/en_CA.js index 46e62eff..484ba326 100644 --- a/definitions/en_CA.js +++ b/definitions/en_CA.js @@ -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
`, + "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", diff --git a/languages/en_CA.json b/languages/en_CA.json index 018450e7..8f10cd23 100644 --- a/languages/en_CA.json +++ b/languages/en_CA.json @@ -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", diff --git a/libs/notification.js b/libs/notification.js index 85b94378..a4727e95 100644 --- a/libs/notification.js +++ b/libs/notification.js @@ -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)