removed extra priv checks

-removed category check from recentreplies since pids are already
checked
-removed category check from topics/unread.js since topics are filtered
now
-added array checks to src/topics.js
v1.18.x
barisusakli 10 years ago
parent 5c7487c13b
commit 6b13a84d2f

@ -16,10 +16,6 @@ module.exports = function(Categories) {
if(!parseInt(count, 10)) {
return callback(null, []);
}
privileges.categories.can('read', cid, uid, function(err, canRead) {
if (err || !canRead) {
return callback(err, []);
}
db.getSortedSetRevRange('cid:' + cid + ':pids', 0, count - 1, function(err, pids) {
if (err || !Array.isArray(pids) || !pids.length) {
@ -33,7 +29,6 @@ module.exports = function(Categories) {
}
], callback);
});
});
};
Categories.getRecentTopicReplies = function(categoryData, uid, callback) {

@ -318,6 +318,9 @@ var async = require('async'),
};
Topics.getTopicsFields = function(tids, fields, callback) {
if (!Array.isArray(tids) || !tids.length) {
return callback(null, []);
}
var keys = tids.map(function(tid) {
return 'topic:' + tid;
});

@ -105,7 +105,7 @@ module.exports = function(Topics) {
tids = tids.slice(start, stop + 1);
}
callback(err, tids);
callback(null, tids);
});
});
};
@ -115,45 +115,22 @@ module.exports = function(Topics) {
return callback(null, tids);
}
privileges.topics.filter('read', tids, uid, function(err, tids) {
if (err || !tids.length) {
return callback(err, []);
}
var keys = tids.map(function(tid) {
return 'topic:' + tid;
});
db.getObjectsFields(keys, ['tid', 'cid'], function(err, topics) {
if (err) {
return callback(err);
}
var topicCids = topics.filter(function(topic) {
return topic && topic.cid;
}).map(function(topic) {
return topic.cid.toString();
});
topicCids = topicCids.filter(function(cid) {
return ignoredCids.indexOf(cid) === -1;
});
privileges.categories.filterCids('read', topicCids, uid, function(err, readableCids) {
if (err) {
return callback(err);
}
topics = topics.filter(function(topic) {
return topic.cid && readableCids.indexOf(topic.cid.toString()) !== -1;
async.waterfall([
function(next) {
privileges.topics.filter('read', tids, uid, next);
},
function(tids, next) {
Topics.getTopicsFields(tids, ['tid', 'cid'], next);
},
function(topics, next) {
tids = topics.filter(function(topic) {
return topic && topic.cid && ignoredCids.indexOf(topic.cid.toString()) === -1;
}).map(function(topic) {
return topic.tid;
});
callback(null, topics);
});
});
});
next(null, tids);
}
], callback);
}
Topics.pushUnreadCount = function(uid, callback) {

Loading…
Cancel
Save