fixing notifications not being called when same adapter has been used twice

This commit is contained in:
orangecoding
2021-03-29 10:02:55 +02:00
parent 0f27429fe0
commit 9726079f62

View File

@@ -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);
};