Node.js based forum software built for the modern web
deleting and restoring posts and topics now update the corresponding RSS feeds
Julian Lamb8b6558f536b
diff --git a/src/feed.js b/src/feed.jsindex 59910c7ec0..37a747bea6 100644--- a/src/feed.js+++ b/src/feed.js@@ -46,17 +46,19 @@if (topicData.main_posts.length > 0) feed.pubDate = new Date(parseInt(topicData.main_posts[0].timestamp, 10)).toUTCString();for (var i = 0, ii = topic_posts.length; i < ii; i++) {- postData = topic_posts[i];- dateStamp = new Date(parseInt(postData.edited === '0' ? postData.timestamp : postData.edited, 10)).toUTCString();- title = 'Reply to ' + topicData.topic_name + ' on ' + dateStamp;-- feed.item({- title: title,- description: postData.content,- url: nconf.get('url') + 'topic/' + topicData.slug + '#' + postData.pid,- author: postData.username,- date: dateStamp- });+ if (topic_posts[i].deleted === '0') {+ postData = topic_posts[i];+ dateStamp = new Date(parseInt(postData.edited === '0' ? postData.timestamp : postData.edited, 10)).toUTCString();+ title = 'Reply to ' + topicData.topic_name + ' on ' + dateStamp;++ feed.item({+ title: title,+ description: postData.content,+ url: nconf.get('url') + 'topic/' + topicData.slug + '#' + postData.pid,+ author: postData.username,+ date: dateStamp+ });+ }}Feed.saveFeed('feeds/topics/' + tid + '.rss', feed, function(err) {diff --git a/src/postTools.js b/src/postTools.jsindex d8e97cc66f..2006abc0c2 100644--- a/src/postTools.js+++ b/src/postTools.js@@ -11,7 +11,8 @@ var RDB = require('./redis.js'),postSearch = reds.createSearch('nodebbpostsearch'),topicSearch = reds.createSearch('nodebbtopicsearch'),winston = require('winston'),- meta = require('./meta.js');+ meta = require('./meta.js'),+ Feed = require('./feed');(function(PostTools) {PostTools.isMain = function(pid, tid, callback) {@@ -138,6 +139,8 @@ var RDB = require('./redis.js'),});}});++ Feed.updateTopic(postData.tid);});};@@ -174,6 +177,8 @@ var RDB = require('./redis.js'),}});+ Feed.updateTopic(postData.tid);+postSearch.index(postData.content, pid);});};diff --git a/src/topics.js b/src/topics.jsindex 59922b7778..88cadc7045 100644--- a/src/topics.js+++ b/src/topics.js@@ -749,6 +749,10 @@ var RDB = require('./redis.js')Topics.delete = function(tid) {Topics.setTopicField(tid, 'deleted', 1);RDB.zrem('topics:recent', tid);++ Topics.getTopicField(tid, 'cid', function(err, cid) {+ feed.updateCategory(cid);+ });}Topics.restore = function(tid) {@@ -756,6 +760,10 @@ var RDB = require('./redis.js')Topics.getTopicField(tid, 'lastposttime', function(err, lastposttime) {RDB.zadd('topics:recent', lastposttime, tid);});++ Topics.getTopicField(tid, 'cid', function(err, cid) {+ feed.updateCategory(cid);+ });}Topics.reIndexTopic = function(tid, callback) {