From a7a6d1bb271a45af1de7d0d07a995b86e9783f21 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 20 Jun 2024 21:59:14 -0400 Subject: [PATCH] fix: use contentSnippet instead of content (so no markdown skipParsing shenanigans) --- index.js | 15 --------------- lib/feed.js | 2 +- lib/pull.js | 5 +---- plugin.json | 4 +--- 4 files changed, 3 insertions(+), 23 deletions(-) diff --git a/index.js b/index.js index 2d88e64..573aa9b 100644 --- a/index.js +++ b/index.js @@ -96,18 +96,3 @@ RssPlugin.widgets.defineWidgets = widget.defineWidgets; * Called on `filter:widget.render:rss` */ RssPlugin.widgets.renderRssWidget = widget.render; - -RssPlugin.skipMarkdown = async ({ env, data }) => { - const feedUrls = await db.getSetMembers('nodebb-plugin-rss:feeds'); - const keys = feedUrls.map(url => `nodebb-plugin-rss:feed:${url}:uuid`); - const { tid } = data.postData; - - if (utils.isNumber(tid)) { - const entries = await db.getSortedSetRangeByScore(keys, 0, 1, tid, tid); - if (entries.length) { - env.parse = false; - } - } - - return { env, data }; -}; diff --git a/lib/feed.js b/lib/feed.js index f53e05e..1670d5d 100644 --- a/lib/feed.js +++ b/lib/feed.js @@ -21,7 +21,7 @@ Feed.getItems = async function (feedUrl, entriesToPull = Feed.DEFAULT_ENTRIES_TO published: item.pubDate, link: { href: item.link }, id: item.guid || item.id, - content: item.content, + content: item.contentSnippet, tags: item.categories, })); }; diff --git a/lib/pull.js b/lib/pull.js index 4fbca1f..1ce3cc6 100644 --- a/lib/pull.js +++ b/lib/pull.js @@ -76,13 +76,10 @@ async function postEntry(feed, entry) { winston.info(`[plugin-rss] posting, ${feed.url} - title: ${entry.title}, published date: ${getEntryDate(entry)}`); const url = entry.link && entry.link.href; - const content = !entry.content.includes(url) ? - `${entry.content}

${url}` : - entry.content; const result = await topics.post({ uid: posterUid, title: entry.title, - content, + content: `${entry.content}\n\n----\n\n${url}`, cid: feed.category, tags: tags, }); diff --git a/plugin.json b/plugin.json index 6b23da0..caafa8f 100644 --- a/plugin.json +++ b/plugin.json @@ -14,9 +14,7 @@ { "hook": "action:topic.purge", "method": "onTopicPurge"}, { "hook": "filter:widgets.getWidgets", "method": "widgets.defineWidgets" }, - { "hook": "filter:widget.render:rss", "method": "widgets.renderRssWidget" }, - - { "hook": "filter:markdown.beforeParse", "method": "skipMarkdown" } + { "hook": "filter:widget.render:rss", "method": "widgets.renderRssWidget" } ], "templates": "./templates", "modules": {