Skip to content

Commit

Permalink
fix(RSS Feed Trigger Node): Save last item's date instead of last exe…
Browse files Browse the repository at this point in the history
…cution date
  • Loading branch information
sweenu committed Feb 7, 2024
1 parent 053fb5f commit 57eab7d
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ export class RssFeedReadTrigger implements INodeType {
const feedUrl = this.getNodeParameter('feedUrl') as string;

const now = moment().utc().format();
const startDate = (pollData.lastTimeChecked as string) || now;

const endDate = now;
const dateToCheck = (pollData.lastItemDate as string) || (pollData.lastTimeChecked as string) || now;

if (!feedUrl) {
throw new NodeOperationError(this.getNode(), 'The parameter "URL" has to be set!');
Expand Down Expand Up @@ -73,12 +71,12 @@ export class RssFeedReadTrigger implements INodeType {
return [this.helpers.returnJsonArray(feed.items[0])];
}
feed.items.forEach((item) => {
if (Date.parse(item.isoDate as string) >= Date.parse(startDate)) {
if (Date.parse(item.isoDate as string) > Date.parse(dateToCheck)) {
returnData.push(item);
}
});
pollData.lastItemDate = feed.items[0].isoDate;
}
pollData.lastTimeChecked = endDate;

if (Array.isArray(returnData) && returnData.length !== 0) {
return [this.helpers.returnJsonArray(returnData)];
Expand Down

0 comments on commit 57eab7d

Please sign in to comment.