Skip to content

Commit

Permalink
trying to call Gladys service first before module service in notifica…
Browse files Browse the repository at this point in the history
…tion.create()
  • Loading branch information
Pierre-Gilles committed May 25, 2017
1 parent 05a72dd commit 26036aa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/core/notification/notification.create.js
Expand Up @@ -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.`);
Expand Down

0 comments on commit 26036aa

Please sign in to comment.