From 9726079f62deab6cd8cf91c70927721a70e3007c Mon Sep 17 00:00:00 2001 From: orangecoding Date: Mon, 29 Mar 2021 10:02:55 +0200 Subject: [PATCH] fixing notifications not being called when same adapter has been used twice --- lib/notification/notify.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/notification/notify.js b/lib/notification/notify.js index d957d1e..9df1446 100755 --- a/lib/notification/notify.js +++ b/lib/notification/notify.js @@ -13,9 +13,12 @@ if (adapter.length === 0) { exports.send = (serviceName, newListings, notificationConfig, jobKey) => { //this is not being used in tests, therefore adapter are always set - return adapter - .filter((notificationAdapter) => { - return notificationConfig.find((config) => config.id === notificationAdapter.config.id); - }) + return notificationConfig + .filter((notificationAdapter) => findAdapter(notificationAdapter) != null) + .map((notificationAdapter) => findAdapter(notificationAdapter)) .map((a) => a.send({ serviceName, newListings, notificationConfig, jobKey })); }; + +const findAdapter = (notificationAdapter) => { + return adapter.find((a) => a.config.id === notificationAdapter.id); +};