Merge pull request #2774 from omnivore-app/fix/api-rss-max
Add a max count to RSS refreshes
This commit is contained in:
@ -187,6 +187,7 @@ export const rssHandler = Sentry.GCPFunction.wrapHttpFunction(
|
||||
let lastValidItem: Item | null = null
|
||||
|
||||
// fetch feed
|
||||
let itemCount = 0
|
||||
const feed = await parser.parseURL(feedUrl)
|
||||
console.log('Fetched feed', feed.title, new Date())
|
||||
|
||||
@ -220,6 +221,11 @@ export const rssHandler = Sentry.GCPFunction.wrapHttpFunction(
|
||||
lastValidItem = item
|
||||
}
|
||||
|
||||
// Max limit per-feed update
|
||||
if (itemCount > 99) {
|
||||
continue
|
||||
}
|
||||
|
||||
// skip old items and items that were published before 24h
|
||||
if (
|
||||
publishedAt < new Date(lastFetchedAt) ||
|
||||
@ -239,6 +245,8 @@ export const rssHandler = Sentry.GCPFunction.wrapHttpFunction(
|
||||
if (!lastItemFetchedAt || publishedAt > lastItemFetchedAt) {
|
||||
lastItemFetchedAt = publishedAt
|
||||
}
|
||||
|
||||
itemCount = itemCount + 1
|
||||
}
|
||||
|
||||
// no items saved
|
||||
|
||||
Reference in New Issue
Block a user