mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 16:30:34 +01:00
updated getTopicWithPosts to use a start and end option, and fixed issue with RSS feed saving (issue #256)
This commit is contained in:
10
src/feed.js
10
src/feed.js
@@ -5,10 +5,13 @@
|
|||||||
topics = require('./topics.js'),
|
topics = require('./topics.js'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
rss = require('node-rss'),
|
rss = require('node-rss'),
|
||||||
winston = require('winston');
|
winston = require('winston'),
|
||||||
|
path = require('path');
|
||||||
|
|
||||||
function saveFeed(location, feed) {
|
function saveFeed(location, feed) {
|
||||||
fs.writeFile(location, rss.getFeedXML(feed), function (err) {
|
var savePath = path.join(__dirname, '../', location);
|
||||||
|
|
||||||
|
fs.writeFile(savePath, rss.getFeedXML(feed), function (err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
winston.err(err);
|
winston.err(err);
|
||||||
}
|
}
|
||||||
@@ -30,9 +33,10 @@
|
|||||||
|
|
||||||
|
|
||||||
Feed.updateTopic = function(tid, cid) {
|
Feed.updateTopic = function(tid, cid) {
|
||||||
|
winston.info('[RSS] Updating RSS feeds for topic ' + tid);
|
||||||
var cache_time_in_seconds = 60;
|
var cache_time_in_seconds = 60;
|
||||||
|
|
||||||
topics.getTopicWithPosts(tid, 0, function(err, topicData) {
|
topics.getTopicWithPosts(tid, 0, 0, -1, function(err, topicData) {
|
||||||
if (err) winston.error('Problem saving topic RSS feed', err.stack);
|
if (err) winston.error('Problem saving topic RSS feed', err.stack);
|
||||||
|
|
||||||
var location = '/topic/' + topicData.slug,
|
var location = '/topic/' + topicData.slug,
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ var user = require('./../user.js'),
|
|||||||
|
|
||||||
app.get('/api/topic/:id/:slug?', function(req, res, next) {
|
app.get('/api/topic/:id/:slug?', function(req, res, next) {
|
||||||
var uid = (req.user) ? req.user.uid : 0;
|
var uid = (req.user) ? req.user.uid : 0;
|
||||||
topics.getTopicWithPosts(req.params.id, uid, function(err, data) {
|
topics.getTopicWithPosts(req.params.id, uid, 0, 10, function(err, data) {
|
||||||
if(data.deleted === '1' && data.expose_tools === 0) {
|
if(data.deleted === '1' && data.expose_tools === 0) {
|
||||||
return res.json(404, {});
|
return res.json(404, {});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ var RDB = require('./redis.js')
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Topics.getTopicWithPosts = function(tid, current_user, callback) {
|
Topics.getTopicWithPosts = function(tid, current_user, start, end, callback) {
|
||||||
threadTools.exists(tid, function(exists) {
|
threadTools.exists(tid, function(exists) {
|
||||||
if (!exists)
|
if (!exists)
|
||||||
return callback(new Error('Topic tid \'' + tid + '\' not found'));
|
return callback(new Error('Topic tid \'' + tid + '\' not found'));
|
||||||
@@ -338,7 +338,7 @@ var RDB = require('./redis.js')
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getTopicPosts(next) {
|
function getTopicPosts(next) {
|
||||||
Topics.getTopicPosts(tid, 0, 10, current_user, function(topicPosts, privileges) {
|
Topics.getTopicPosts(tid, start, end, current_user, function(topicPosts, privileges) {
|
||||||
next(null, topicPosts);
|
next(null, topicPosts);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ var express = require('express'),
|
|||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function(next) {
|
function(next) {
|
||||||
topics.getTopicWithPosts(tid, ((req.user) ? req.user.uid : 0), function(err, topicData) {
|
topics.getTopicWithPosts(tid, ((req.user) ? req.user.uid : 0), 0, -1, function(err, topicData) {
|
||||||
if(topicData) {
|
if(topicData) {
|
||||||
if(topicData.deleted === '1' && topicData.expose_tools === 0)
|
if(topicData.deleted === '1' && topicData.expose_tools === 0)
|
||||||
return next(new Error('Topic deleted'), null);
|
return next(new Error('Topic deleted'), null);
|
||||||
|
|||||||
Reference in New Issue
Block a user