Email Notification settings are now configurable in Account Settings

Email settings in conf.json are separate from Account Settings configurations. To hide all System Level (conf.json) Email settings : remove `mail` object from your conf.json.
p2p-v2
Moe 2022-02-07 11:15:11 -08:00
parent 469f0af18f
commit 5709a3f140
5 changed files with 147 additions and 145 deletions

View File

@ -2852,17 +2852,6 @@ module.exports = function(s,config,lang){
"form-group-class-pre-layer": "h_rec_mtd_input h_rec_mtd_hot h_rec_mtd_sip",
"possible": ""
},
{
hidden: true,
"name": "detail=detector_send_video_length",
"field": lang["Notification Video Length"],
"description": "In seconds. The length of the video that gets sent to your Notification service, like Email or Discord.",
"default": "10",
"example": "",
"form-group-class": "h_det_input h_det_1",
"form-group-class-pre-layer": "h_rec_mtd_input h_rec_mtd_hot h_rec_mtd_sip",
"possible": ""
},
{
hidden: true,
"name": "detail=watchdog_reset",
@ -3084,35 +3073,6 @@ module.exports = function(s,config,lang){
"form-group-class": "h_det_input h_det_1",
"default": "0",
},
{
"name": "detail=detector_mail",
"field": lang['Email on Trigger'],
"description": "Recieve an email of an image during a motion event to the master account for the camera group. You must setup SMTP details in conf.json.",
"default": "0",
"example": "",
"selector": "h_det_email",
"fieldType": "select",
"form-group-class-pre-layer": "h_det_input h_det_1",
"possible": [
{
"name": lang.No,
"value": "0"
},
{
"name": lang.Yes,
"value": "1"
}
]
},
{
"name": "detail=detector_mail_timeout",
"field": lang['Allow Next Email'],
"description": "The amount of time until a trigger is allowed to send another email with motion details and another image.",
"default": "10",
"example": "",
"form-group-class-pre-layer": "h_det_input h_det_1",
"possible": ""
},
{
"name": "detail=use_detector_filters",
"field": lang['Event Filters'],
@ -3346,22 +3306,12 @@ module.exports = function(s,config,lang){
]
},
{
"name": "detail=detector_notrigger_mail",
"field": lang['Email'],
"description": "If motion has not been detected after the timeout period you will recieve an email.",
"default": "0",
"name": "detail=detector_notrigger_timeout",
"field": lang.Timeout,
"description": "Timeout is calculated in minutes.",
"default": "10",
"example": "",
"fieldType": "select",
"possible": [
{
"name": lang.No,
"value": "0"
},
{
"name": lang.Yes,
"value": "1"
}
]
"possible": ""
},
{
"name": "detail=detector_notrigger_discord",
@ -3381,14 +3331,6 @@ module.exports = function(s,config,lang){
}
]
},
{
"name": "detail=detector_notrigger_timeout",
"field": lang.Timeout,
"description": "Timeout is calculated in minutes.",
"default": "10",
"example": "",
"possible": ""
},
{
"name": "detail=detector_notrigger_webhook",
"field": "Webhook",
@ -4494,32 +4436,13 @@ module.exports = function(s,config,lang){
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"
}
]
},
],
},
{
@ -4556,6 +4479,15 @@ module.exports = function(s,config,lang){
}
]
},
{
hidden: true,
"name": "detail=detector_send_video_length",
"field": lang["Notification Video Length"],
"description": "In seconds. The length of the video that gets sent to your Notification service, like Email or Discord.",
"default": "10",
"example": "",
"possible": ""
},
]
},
"Logging": {
@ -4741,24 +4673,6 @@ module.exports = function(s,config,lang){
}
]
},
{
"name": "detail=factor_mail",
"field": lang.Email,
"description": "Send 2-Factor Authentication codes to the email address of the account.",
"default": "1",
"example": "",
"fieldType": "select",
"possible": [
{
"name": lang.No,
"value": "0"
},
{
"name": lang.Yes,
"value": "1"
}
]
},
]
},
"Profile": {

View File

@ -40,6 +40,7 @@
"Admin": "Admin",
"Superuser": "Superuser",
"Dashcam": "Dashcam",
"System Level": "System Level",
"Email": "Email",
"Username": "Username",
"Profile": "Profile",
@ -721,7 +722,7 @@
"Allow Next Command": "Allow Next Command",
"Allow Next Trigger": "Allow Next Trigger",
"Save Events to SQL": "Save Events to SQL",
"Email on Trigger": "Email on Trigger <small>Emails go to the main account holder's login address.</small>",
"Email on Trigger": "Email on Trigger",
"Attach Video Clip": "Attach Video Clip",
"Error While Decoding": "Error While Decoding",
"ErrorWhileDecodingText": "Your hardware may have an unstable connection to the network. Check your network connections.",

View File

@ -10,7 +10,15 @@ module.exports = function(s,config,lang){
d.screenshotBuffer = screenShot
}
}
require('./notifications/email.js')(s,config,lang,getSnapshot)
if(
config.mail &&
config.mail.auth &&
config.mail.auth.user !== 'your_email@gmail.com' &&
config.mail.auth.pass !== 'your_password_or_app_specific_password'
){
require('./notifications/email.js')(s,config,lang,getSnapshot)
}
require('./notifications/emailByUser.js')(s,config,lang,getSnapshot)
require('./notifications/discordBot.js')(s,config,lang,getSnapshot)
require('./notifications/telegram.js')(s,config,lang,getSnapshot)
require('./notifications/pushover.js')(s,config,lang,getSnapshot)

View File

@ -240,9 +240,27 @@ module.exports = function(s,config,lang,getSnapshot){
s.onFilterEvent(onFilterEventForEmail)
s.onDetectorNoTriggerTimeout(onDetectorNoTriggerTimeoutForEmail)
s.onMonitorUnexpectedExit(onMonitorUnexpectedExitForEmail)
s.definitions['Account Settings'].blocks['2-Factor Authentication'].info.push( {
"name": "detail=factor_mail",
"field": `${lang.Email} (${lang['System Level']})`,
"description": "Send 2-Factor Authentication codes to the email address of the account.",
"default": "1",
"example": "",
"fieldType": "select",
"possible": [
{
"name": lang.No,
"value": "0"
},
{
"name": lang.Yes,
"value": "1"
}
]
});
s.definitions["Event Filters"].blocks["Action for Selected"].info.push( {
"name": "actions=mail",
"field": "Email on Trigger",
"field": `${lang['Email on Trigger']} (${lang['System Level']})`,
"fieldType": "select",
"form-group-class": "actions-row",
"default": "",
@ -259,6 +277,75 @@ module.exports = function(s,config,lang,getSnapshot){
}
]
})
s.definitions['Monitor Settings'].blocks['Notifications'].info[0].info.push(
{
"name": "detail=notify_email",
"field": `${lang.Email} (${lang['System Level']})`,
"default": "0",
"fieldType": "select",
"possible": [
{
"name": lang.No,
"value": "0"
},
{
"name": lang.Yes,
"value": "1"
}
]
},
)
s.definitions['Monitor Settings'].blocks['Notifications'].info.push(
{
isFormGroupGroup: true,
name: `${lang.Email} (${lang['System Level']})`,
color: 'blue',
'section-class': 'h_det_input h_det_1',
info: [
{
"name": "detail=detector_mail",
"field": lang['Email on Trigger'],
"description": "Recieve an email of an image during a motion event to the master account for the camera group. You must setup SMTP details in conf.json.",
"default": "0",
"selector": "h_det_email",
"fieldType": "select",
"possible": [
{
"name": lang.No,
"value": "0"
},
{
"name": lang.Yes,
"value": "1"
}
]
},
{
"name": "detail=detector_mail_timeout",
"field": lang['Allow Next Email'],
"description": "The amount of time until a trigger is allowed to send another email with motion details and another image.",
"default": "10",
},
{
"name": "detail=detector_notrigger_mail",
"field": lang['No Trigger'],
"description": "If motion has not been detected after the timeout period you will recieve an email.",
"default": "0",
"fieldType": "select",
"possible": [
{
"name": lang.No,
"value": "0"
},
{
"name": lang.Yes,
"value": "1"
}
]
},
],
}
);
}catch(err){
console.log(err)
}

View File

@ -23,29 +23,28 @@ module.exports = function (s, config, lang, getSnapshot) {
return;
}
try {
const appOptions = s.group[groupKey].emailClientOptions.transport;
const sendTo = appOptions.sendTo;
const sendData = {
from: `"shinobi.video" <${transportOptions.auth.user}>`,
to: sendTo,
subject: sendBody.subject,
html: sendBody.html,
};
if (files.length > 0) {
// sadly pushover allows only ONE single attachment
msg.file = {
name: files[0].name,
data: files[0].attachment,
const emailClientOptions = s.group[groupKey].emailClientOptions;
const appOptions = emailClientOptions.transport;
const sendTo = emailClientOptions.sendTo;
sendTo.split(',').forEach((reciepientAddress) => {
const sendData = {
from: `"shinobi.video" <${appOptions.auth.user}>`,
to: reciepientAddress,
subject: sendBody.subject,
html: sendBody.html,
attachments: files || []
};
}
transporter.sendMail(sendData, function (err, result) {
if (err) {
throw err;
}
s.userLog(result);
s.debugLog(result);
});
transporter.sendMail(sendData, function (err, result) {
if (err) {
throw err;
}
s.userLog(result);
s.debugLog(result);
});
})
console.log(sendBody)
} catch (err) {
s.debugLog(err)
s.userLog(
{ ke: groupKey, mid: '$USER' },
{ type: lang.NotifyErrorText, msg: err }
@ -119,18 +118,10 @@ module.exports = function (s, config, lang, getSnapshot) {
!s.group[d.ke].activeMonitors[d.id].detector_emailClient
) {
var detector_emailClient_timeout;
if (
!monitorConfig.details.detector_emailClient_timeout ||
monitorConfig.details.detector_emailClient_timeout === ''
) {
detector_emailClient_timeout = 1000 * 60 * 10;
} else {
detector_emailClient_timeout =
parseFloat(
monitorConfig.details.detector_emailClient_timeout
) *
1000 *
60;
if (!monitorConfig.details.detector_emailClient_timeout){
detector_emailClient_timeout = 1000 * 60 * 10
}else{
detector_emailClient_timeout = parseFloat(monitorConfig.details.detector_emailClient_timeout) * 1000 * 60
}
s.group[d.ke].activeMonitors[d.id].detector_emailClient = setTimeout(function () {
s.group[d.ke].activeMonitors[d.id].detector_emailClient = null;
@ -157,7 +148,7 @@ module.exports = function (s, config, lang, getSnapshot) {
subtitle: lang.Event,
body: infoRows.join(''),
}),
},files || [],r.ke)
},files || [],d.ke)
}
if(monitorConfig.details.detector_mail_send_video === '1'){
let videoPath = null
@ -255,9 +246,7 @@ module.exports = function (s, config, lang, getSnapshot) {
s.onEventTriggerBeforeFilter(onEventTriggerBeforeFilterForApp);
s.onDetectorNoTriggerTimeout(onDetectorNoTriggerTimeoutForApp);
s.onMonitorUnexpectedExit(onMonitorUnexpectedExitForApp);
s.definitions['Monitor Settings'].blocks[
'Notifications'
].info[0].info.push({
s.definitions['Monitor Settings'].blocks['Notifications'].info[0].info.push({
name: 'detail=notify_emailClient',
field: lang.Email,
description: '',
@ -292,9 +281,7 @@ module.exports = function (s, config, lang, getSnapshot) {
],
}
);
s.definitions['Account Settings'].blocks[
'2-Factor Authentication'
].info.push({
s.definitions['Account Settings'].blocks['2-Factor Authentication'].info.push({
name: 'detail=factor_emailClient',
field: lang.Email,
default: '1',
@ -313,7 +300,8 @@ module.exports = function (s, config, lang, getSnapshot) {
});
s.definitions['Account Settings'].blocks['Email'] = {
evaluation: "$user.details.use_emailClient !== '0'",
field: lang.Email,
name: lang.Email,
id: lang.Email,
color: 'blue',
info: [
{
@ -349,7 +337,9 @@ module.exports = function (s, config, lang, getSnapshot) {
'form-group-class': 'u_emailClient_input u_emailClient_1',
},
{
hidden: true,
name: 'detail=emailClient_secure',
'form-group-class': 'u_emailClient_input u_emailClient_1',
field: lang.Secure,
default: '0',
example: '',
@ -375,6 +365,7 @@ module.exports = function (s, config, lang, getSnapshot) {
{
hidden: true,
field: lang.Password,
fieldType: 'password',
name: 'detail=emailClient_pass',
'form-group-class': 'u_emailClient_input u_emailClient_1',
},
@ -382,6 +373,7 @@ module.exports = function (s, config, lang, getSnapshot) {
hidden: true,
field: lang['Send to'],
name: 'detail=emailClient_sendTo',
example: 'testrecipient@gmail.com',
'form-group-class': 'u_emailClient_input u_emailClient_1',
},
],