feat(bot): implement filtering on published threshold param
This commit is contained in:
parent
c99b6d6a46
commit
72fe545211
@ -51,6 +51,12 @@ const processItems = async (items: RssParser.Item[], feed: ExpandedFeed, channel
|
|||||||
console.log(`Processing ${items.length} items`);
|
console.log(`Processing ${items.length} items`);
|
||||||
|
|
||||||
for (let i = items.length; i--;) {
|
for (let i = items.length; i--;) {
|
||||||
|
if (new Date(items[i].pubDate!) < feed.published_threshold) {
|
||||||
|
console.log(`skipping outdated item: ${items[i].title}`)
|
||||||
|
items.splice(i, 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(await Promise.all(feed.filters.map(f => passesFilter(f, items[i])))).every(Boolean)) {
|
if (!(await Promise.all(feed.filters.map(f => passesFilter(f, items[i])))).every(Boolean)) {
|
||||||
items.splice(i, 1);
|
items.splice(i, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user