diff --git a/packages/rss-handler/src/index.ts b/packages/rss-handler/src/index.ts index 4edd58709..048592c27 100644 --- a/packages/rss-handler/src/index.ts +++ b/packages/rss-handler/src/index.ts @@ -242,6 +242,15 @@ export const rssHandler = Sentry.GCPFunction.wrapHttpFunction( const feed = await parser.parseString(fetchResult.content) console.log('Fetched feed', feed.title, new Date()) + const feedPubDate = (feed['dc:date'] || + feed.pubDate || + feed.lastBuildDate) as string | undefined + console.log('Feed pub date', feedPubDate) + if (feedPubDate && new Date(feedPubDate) < new Date(lastFetchedAt)) { + console.log('Skipping old feed', feedPubDate) + return res.send('ok') + } + // save each item in the feed for (const item of feed.items) { // use published or updated if isoDate is not available for atom feeds