--- a/controllers/controllerV0.js
+++ b/controllers/controllerV0.js
@@ -79,7 +79,8 @@
//Check if Token Exists
database.checkIfTokenExists(req.body.token, function(isOK, reason){
if(isOK) {
- controllerNotification.notificationsCheck(req.body.body, req.body.emailTo, req.body.token, function(isOK, reason){
+ //controllerNotification.notificationsCheck(req.body.body, req.body.emailTo, req.body.token, function(isOK, reason){
+ controllerNotification.notificationHandler(req.body.body, req.body.emailTo, req.body.token, function(ifOK, reason){
if(isOK) {
sendResponse(200, {success: true, reason:reason},"Notification: Success", res);
}else {
@@ -99,16 +100,23 @@
logger.info("Request type: ",req.method, "Request URL: ", req.originalUrl);
var handler = "backend.controllers.createNotificationsRules";
logger.info("Starting: ",handler);
- if(Object.keys(req.body).length != 0){
- database.insertNotificationRules(req.body, function(isOK, data){
- if(!isOK) {
- logger.info(handler,data);
- sendResponse(500, {success:false, data:data},"Create Rules: "+data, res);
- }else {
- logger.info(handler,data);
- sendResponse(200, {success: true, data:data},"Create Rules: Success", res);
- }
- });
+ var response = [];
+ if(Object.keys(req.body).length != 0){
+ req.body.forEach(function(eachBody, index){
+ database.insertNotificationRules(eachBody, function(isOK, data){
+ if(!isOK) {
+ logger.info(handler,data);
+ response.push({description: eachBody.description, success: true })
+ }else {
+ logger.info(handler,data);
+ response.push({description: eachBody.description, success: false })
+ }
+ });
+ if(req.body.length-1 == index){
+ sendResponse(200, {success:true, data:response},"Create Rules: "+response, res);
+ }
+ })
+
}else{
logger.error(handler);
res.end();