mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-25 16:11:19 +01:00
closes #5903
This commit is contained in:
@@ -22,7 +22,7 @@ recentController.get = function (req, res, next) {
|
||||
var cid = req.query.cid;
|
||||
var filter = req.params.filter || '';
|
||||
var categoryData;
|
||||
|
||||
var rssToken;
|
||||
if (!validFilter[filter]) {
|
||||
return next();
|
||||
}
|
||||
@@ -36,9 +36,13 @@ recentController.get = function (req, res, next) {
|
||||
watchedCategories: function (next) {
|
||||
helpers.getWatchedCategories(req.uid, cid, next);
|
||||
},
|
||||
rssToken: function (next) {
|
||||
user.auth.getFeedToken(req.uid, next);
|
||||
},
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
rssToken = results.rssToken;
|
||||
settings = results.settings;
|
||||
categoryData = results.watchedCategories;
|
||||
|
||||
@@ -54,6 +58,9 @@ recentController.get = function (req, res, next) {
|
||||
data.set = 'topics:recent';
|
||||
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
|
||||
data.rssFeedUrl = nconf.get('relative_path') + '/recent.rss';
|
||||
if (req.uid) {
|
||||
data.rssFeedUrl += '?uid=' + req.uid + '&token=' + rssToken;
|
||||
}
|
||||
data.title = '[[pages:recent]]';
|
||||
data.filters = [{
|
||||
name: '[[unread:all-topics]]',
|
||||
|
||||
@@ -185,13 +185,28 @@ function generateForRecent(req, res, next) {
|
||||
if (parseInt(meta.config['feeds:disableRSS'], 10) === 1) {
|
||||
return controllers404.send404(req, res);
|
||||
}
|
||||
generateForTopics({
|
||||
uid: req.uid,
|
||||
title: 'Recently Active Topics',
|
||||
description: 'A list of topics that have been active within the past 24 hours',
|
||||
feed_url: '/recent.rss',
|
||||
site_url: '/recent',
|
||||
}, 'topics:recent', req, res, next);
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
if (req.query.token && req.query.uid) {
|
||||
db.getObjectField('user:' + req.query.uid, 'rss_token', next);
|
||||
} else {
|
||||
next(null, null);
|
||||
}
|
||||
},
|
||||
function (token, next) {
|
||||
next(null, token && token === req.query.token ? req.query.uid : req.uid);
|
||||
},
|
||||
function (uid, next) {
|
||||
generateForTopics({
|
||||
uid: uid,
|
||||
title: 'Recently Active Topics',
|
||||
description: 'A list of topics that have been active within the past 24 hours',
|
||||
feed_url: '/recent.rss',
|
||||
site_url: '/recent',
|
||||
}, 'topics:recent', req, res, next);
|
||||
},
|
||||
], next);
|
||||
}
|
||||
|
||||
function generateForPopular(req, res, next) {
|
||||
@@ -230,7 +245,7 @@ function generateForTopics(options, set, req, res, next) {
|
||||
var stop = options.hasOwnProperty('stop') ? options.stop : 19;
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
topics.getTopicsFromSet(set, req.uid, start, stop, next);
|
||||
topics.getTopicsFromSet(set, options.uid, start, stop, next);
|
||||
},
|
||||
function (data, next) {
|
||||
generateTopicsFeed(options, data.topics, next);
|
||||
|
||||
Reference in New Issue
Block a user