Skip to content

Commit

Permalink
fix: use contentSnippet instead of content (so no markdown skipParsin…
Browse files Browse the repository at this point in the history
…g shenanigans)
  • Loading branch information
julianlam committed Jun 21, 2024
1 parent db4b791 commit a7a6d1b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 23 deletions.
15 changes: 0 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};
2 changes: 1 addition & 1 deletion lib/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}));
};
Expand Down
5 changes: 1 addition & 4 deletions lib/pull.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}<hr /><p><a href="${url}">${url}</a>` :
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,
});
Expand Down
4 changes: 1 addition & 3 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit a7a6d1b

Please sign in to comment.