Skip to content

Commit

Permalink
fixing notifications not being called when same adapter has been used…
Browse files Browse the repository at this point in the history
… twice
  • Loading branch information
orangecoding committed Mar 29, 2021
1 parent 0f27429 commit 9726079
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/notification/notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

0 comments on commit 9726079

Please sign in to comment.