From: xangelo Date: Sat, 27 Jan 2024 03:49:57 +0000 (-0500) Subject: clean up bugs around feed checking X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=5142cfa2b91ee6e1dab7963dcafb7fc73605a3ab;p=river.git clean up bugs around feed checking --- diff --git a/src/server.ts b/src/server.ts index 579f3ee..707c0a0 100644 --- a/src/server.ts +++ b/src/server.ts @@ -26,6 +26,8 @@ function contentExtractor(feed: FeedSchema, item): string { break; } + str = str.replace(/<[^>]+>/g, ''); + return str; } @@ -35,11 +37,11 @@ async function queryFeeds() { const feedsToQuery = completeFeedList.filter(feed => { // only update every 5 minutes - //return Date.now() > (feed.updated_at + 1000 * 60 * 5); - return true; + return Date.now() > (feed.updated_at + (1000 * 60 * 5)); }); console.log(`Querying ${feedsToQuery.length} feeds`); + const now = Date.now(); for(let feed of feedsToQuery) { console.log(`Querying ${feed.title}(${feed.url})`); @@ -48,14 +50,14 @@ async function queryFeeds() { const items: FeedEntrySchema[] = data.items.map(item => { return { - id: item.guid, + id: item.guid || item.id, title: item.title, link: item.link, feed_id: feed.id, pub_date: Math.floor(new Date(item.pubDate).getTime()/1000), - author: item.creator, - created_at: Math.floor(Date.now()/1000), - updated_at: Math.floor(Date.now()/1000), + author: item.creator || item.author, + created_at: Math.floor(now/1000), + updated_at: Math.floor(now/1000), meta: { comment_link: item.comments, snippet: contentExtractor(feed, item) @@ -70,7 +72,7 @@ async function queryFeeds() { } await db('feeds').update({ - updated_at: new Date() + updated_at: Math.floor(Date.now()/1000) }).where({ id: feed.id }); @@ -164,7 +166,7 @@ app.post('/feeds', async (req, res) => { title: req.body.title, favicon: req.body.favicon, created_at: now, - updated_at: now + updated_at: 0 }; const rows = await db('feeds').insert(feed).onConflict().ignore().returning('*');