Merge branch 'master' of github.com:designcreateplay/NodeBB

v1.18.x
Julian Lam 12 years ago
commit 6f759e840e

@ -128,7 +128,6 @@ var RDB = require('./redis.js'),
Categories.getTopicsByTids = function(tids, current_user, callback, category_id /*temporary*/) {
var retrieved_topics = [];
var topicCountToLoad = tids.length;
function getTopicInfo(topicData, callback) {
@ -177,9 +176,8 @@ var RDB = require('./redis.js'),
return !deleted || (deleted && topicInfo.privileges.view_deleted) || topicData.uid === current_user;
}
for(var i=0; i<tids.length; ++i) {
topics.getTopicData(tids[i], function(topicData) {
function loadTopic(tid, callback) {
topics.getTopicData(tid, function(topicData) {
getTopicInfo(topicData, function(topicInfo) {
@ -198,15 +196,17 @@ var RDB = require('./redis.js'),
if (isTopicVisible(topicData, topicInfo))
retrieved_topics.push(topicData);
else
--topicCountToLoad;
if(retrieved_topics.length === topicCountToLoad) {
callback(retrieved_topics);
}
callback(null);
});
});
}
async.eachSeries(tids, loadTopic, function(err) {
if(!err) {
callback(retrieved_topics);
}
});
}

@ -81,7 +81,7 @@ marked.setOptions({
}
PostTools.delete = function(uid, pid) {
var success = function() {
var success = function() {
posts.setPostField(pid, 'deleted', 1);
@ -116,7 +116,7 @@ marked.setOptions({
}
PostTools.restore = function(uid, pid) {
var success = function() {
var success = function() {
posts.setPostField(pid, 'deleted', 0);
posts.getPostFields(pid, ['tid', 'uid'], function(postData) {
@ -126,6 +126,12 @@ marked.setOptions({
io.sockets.in('topic_' + postData.tid).emit('event:post_restored', {
pid: pid
});
threadTools.get_latest_undeleted_pid(postData.tid, function(err, pid) {
posts.getPostField(pid, 'timestamp', function(timestamp) {
topics.updateTimestamp(postData.tid, timestamp);
});
});
});
};

@ -298,7 +298,6 @@ marked.setOptions({
});
topics.increasePostCount(tid);
topics.setTopicField(tid, 'lastposttime', timestamp);
topics.updateTimestamp(tid, timestamp);
RDB.incr('totalpostcount');

@ -452,6 +452,7 @@ marked.setOptions({
Topics.updateTimestamp = function(tid, timestamp) {
RDB.zadd(schema.topics().recent, timestamp, tid);
Topics.setTopicField(tid, 'lastposttime', timestamp);
}
}(exports));

@ -730,14 +730,14 @@ var utils = require('./../public/src/utils.js'),
User.isModerator = function(uid, cid, callback) {
RDB.sismember('cid:' + cid + ':moderators', uid, function(err, exists) {
// @todo handle error
RDB.handle(err);
callback(!!exists);
});
}
User.isAdministrator = function(uid, callback) {
RDB.sismember('administrators', uid, function(err, exists) {
// @todo handle error
RDB.handle(err);
callback(!!exists);
});
}

Loading…
Cancel
Save