sending job key with the listings

This commit is contained in:
Christian Kellner
2020-07-17 16:34:10 +02:00
parent ee313e401c
commit a58b849f26
6 changed files with 44 additions and 40 deletions

View File

@@ -3,7 +3,7 @@ const {
setKnownListings,
getKnownListings,
setNumberOfTotalFoundProviderListings,
getForTesting
getForTesting,
} = require('./services/store');
const notify = require('./notification/notify');
@@ -79,7 +79,7 @@ class FredyRuntime {
}
_findNew(listings) {
const newListings = listings.filter(o => getKnownListings(this._jobKey, this._providerId).indexOf(o.id) === -1);
const newListings = listings.filter((o) => getKnownListings(this._jobKey, this._providerId).indexOf(o.id) === -1);
if (newListings.length === 0) {
throw new NoNewListingsError();
@@ -89,14 +89,14 @@ class FredyRuntime {
}
_notify(newListings) {
const sendNotifications = notify.send(this._providerId, newListings, this._notificationConfig);
const sendNotifications = notify.send(this._providerId, newListings, this._notificationConfig, this._jobKey);
return Promise.all(sendNotifications).then(() => newListings);
}
_save(newListings) {
setKnownListings(this._jobKey, this._providerId, [
...getKnownListings(this._jobKey, this._providerId),
...newListings.map(l => l.id)
...newListings.map((l) => l.id),
]);
return newListings;
}