Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: save feed entry contents into topic contents #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const db = require.main.require('./src/database');
const pubsub = require.main.require('./src/pubsub');
const routeHelpers = require.main.require('./src/routes/helpers');
const utils = require.main.require('./src/utils');

const database = require('./lib/database');
const controllers = require('./lib/controllers');
Expand Down Expand Up @@ -95,4 +96,3 @@ RssPlugin.widgets.defineWidgets = widget.defineWidgets;
* Called on `filter:widget.render:rss`
*/
RssPlugin.widgets.renderRssWidget = widget.render;

1 change: 1 addition & 0 deletions lib/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +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.contentSnippet,
tags: item.categories,
}));
};
Expand Down
5 changes: 3 additions & 2 deletions lib/pull.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ 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 result = await topics.post({
uid: posterUid,
title: entry.title,
content: entry.link && entry.link.href,
content: `${entry.content}\n\n----\n\n${url}`,
cid: feed.category,
tags: tags,
});
Expand All @@ -92,7 +93,7 @@ async function postEntry(feed, entry) {
const max = Math.max(parseInt(meta.config.postDelay, 10) || 10, parseInt(meta.config.newbiePostDelay, 10) || 10) + 1;

await user.setUserField(posterUid, 'lastposttime', Date.now() - (max * 1000));
const uuid = entry.id || (entry.link && entry.link.href) || entry.title;
const uuid = entry.id || (url) || entry.title;
await db.sortedSetAdd(`nodebb-plugin-rss:feed:${feed.url}:uuid`, topicData.tid, uuid);
}

Expand Down