diff --git a/server.js b/server.js index b842ed3..3f5cb87 100644 --- a/server.js +++ b/server.js @@ -106,19 +106,22 @@ app.get('/core/:id', function(req, res){ app.post('/', function(req, res){ var postEvent = req.body.postEvent; var source = req.body.source; - //console.log("Post event = "+postEvent+", source is "+source); console.log(req.body); - var stmt = db.prepare("INSERT INTO Alerts (OrigJSON, coreid, published_at) VALUES (?, ?, ?)"); + var innerDataJSON = JSON.parse(req.body.data); + var status = JSON.stringify(innerDataJSON.status, null, 4); + var stmt = db.prepare("INSERT INTO Alerts (OrigJSON, coreid, published_at, status) VALUES (?, ?, ?, ?)"); stmt.run( JSON.stringify(req.body, null, 4), JSON.stringify(req.body.coreid, null, 4), - JSON.stringify(req.body.published_at, null, 4) + JSON.stringify(req.body.published_at, null, 4), + status ); stmt.finalize(); // Send emails on alerts only if(JSON.stringify(req.body, null, 4).indexOf('alert') > -1){ + mailOptions.text = status; transporter.sendMail(mailOptions, function(error, info){ if(error){ console.log(error);