From b605d1ed7ec2292f2900915dee6c10b5d83d1884 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Thu, 12 Oct 2017 21:05:34 +0530 Subject: [PATCH] fix: notification for multiple endpoints add silent fail case for notification promise --- src/lib/notify.js | 6 +----- test/functional/notifications/notify.js | 8 +++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/lib/notify.js b/src/lib/notify.js index 8ad49ff61..c77a04f0a 100644 --- a/src/lib/notify.js +++ b/src/lib/notify.js @@ -69,11 +69,7 @@ const notify = function(metadata, config) { return handleNotify(metadata, config.notify); } else { // multiple notifications endpoints PR #108 - for (const key in config.notify) { - if (config.notify.hasOwnProperty(key)) { - return handleNotify(metadata, config.notify[key]); - } - } + return Promise.all(_.map(config.notify, (key) => handleNotify(metadata, key))); } } }; diff --git a/test/functional/notifications/notify.js b/test/functional/notifications/notify.js index f15cc7b86..cbcfbe3c6 100644 --- a/test/functional/notifications/notify.js +++ b/test/functional/notifications/notify.js @@ -86,9 +86,11 @@ module.exports = function() { } notify(metadata, multipleNotificationsEndpoint).then(function (body) { - const jsonBody = JSON.parse(body); - assert.ok(`New package published: * ${metadata.name}*` === jsonBody.message, - 'Body notify message should be equal'); + body.forEach(function(notification) { + const jsonBody = JSON.parse(notification); + assert.ok(`New package published: * ${metadata.name}*` === jsonBody.message, + 'Body notify message should be equal'); + }); done(); }, function (err) { assert.fail(err);