From 26036aa7bdd7f0843c6de0808aa26b8be542af65 Mon Sep 17 00:00:00 2001 From: Pierre-Gilles Leymarie Date: Thu, 25 May 2017 09:57:04 +0200 Subject: [PATCH] trying to call Gladys service first before module service in notification.create() --- api/core/notification/notification.create.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/core/notification/notification.create.js b/api/core/notification/notification.create.js index 6352f64c60..911280ed32 100644 --- a/api/core/notification/notification.create.js +++ b/api/core/notification/notification.create.js @@ -37,13 +37,18 @@ function create(options) { */ function startService(notification, type, user) { - if (!gladys.modules[type.service] || typeof gladys.modules[type.service].notify !== "function") { + var notify = null; + if(gladys[type.service] && typeof gladys[type.service].notify === "function"){ + notify = gladys[type.service].notify; + } else if (gladys.modules[type.service] || typeof gladys.modules[type.service].notify === "function") { + notify = gladys.modules[type.service].notify; + } else { return Promise.reject(new Error(`${type.service} is not a valid service`)); } sails.log.info(`Notification : create : Trying to contact ${type.service}`); - return gladys.modules[type.service].notify(notification, user) + return notify(notification, user) .then(function(result) { sails.log.info(`Notification threw ${type.service} sent with success. Aborting the chain.`);