Merge branch 'ssanri-dashboard-v3-patch-76414' into 'dashboard-v3'

Sercom ICamera1000 fails to store http trigger url when json provided.

See merge request Shinobi-Systems/Shinobi!358
merge-requests/256/merge
Moe 2022-06-04 18:30:18 +00:00
commit f2eb3b0fca
1 changed files with 21 additions and 6 deletions

View File

@ -1366,6 +1366,7 @@ module.exports = function(s,config,lang,app,io){
const groupKey = req.params.ke
const monitorId = req.params.id
const monitorRestrictions = s.getMonitorRestrictions(user.details,monitorId)
if(user.details.sub && user.details.allmonitors === '0' && monitorRestrictions.length === 0){
s.closeJsonResponse(res,{
ok: false,
@ -1373,13 +1374,15 @@ module.exports = function(s,config,lang,app,io){
})
return
}
const d = {
id: req.params.id,
ke: req.params.ke
}
if(req.query.data){
try{
var d = {
id: req.params.id,
ke: req.params.ke,
details: s.parseJSON(req.query.data)
}
Object.assign(d, {details: s.parseJSON(req.query.data)});
}catch(err){
s.closeJsonResponse(res,{
ok: false,
@ -1387,7 +1390,19 @@ module.exports = function(s,config,lang,app,io){
})
return
}
}else{
}
// fallback for cameras that doesn't support JSON in query parameters ( i.e Sercom ICamera1000 will fail to save HTTP_Notifications as invalid url)
else if( req.query.plug && req.query.name && req.query.reason && req.query.confidence) {
Object.assign(d, {
details: {
plug: req.query.plug,
reason: req.query.reason,
confidence: req.query.confidence,
name: req.query.name
}
});
}
else{
s.closeJsonResponse(res,{
ok: false,
msg: user.lang['No Data']