mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 10:06:13 +01:00
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
This commit is contained in:
@@ -16,23 +16,18 @@ module.exports = function(Categories) {
|
|||||||
if(!parseInt(count, 10)) {
|
if(!parseInt(count, 10)) {
|
||||||
return callback(null, []);
|
return callback(null, []);
|
||||||
}
|
}
|
||||||
privileges.categories.can('read', cid, uid, function(err, canRead) {
|
|
||||||
if (err || !canRead) {
|
db.getSortedSetRevRange('cid:' + cid + ':pids', 0, count - 1, function(err, pids) {
|
||||||
|
if (err || !Array.isArray(pids) || !pids.length) {
|
||||||
return callback(err, []);
|
return callback(err, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
db.getSortedSetRevRange('cid:' + cid + ':pids', 0, count - 1, function(err, pids) {
|
async.waterfall([
|
||||||
if (err || !Array.isArray(pids) || !pids.length) {
|
async.apply(privileges.posts.filter, 'read', pids, uid),
|
||||||
return callback(err, []);
|
function(pids, next) {
|
||||||
|
posts.getPostSummaryByPids(pids, uid, {stripTags: true}, next);
|
||||||
}
|
}
|
||||||
|
], callback);
|
||||||
async.waterfall([
|
|
||||||
async.apply(privileges.posts.filter, 'read', pids, uid),
|
|
||||||
function(pids, next) {
|
|
||||||
posts.getPostSummaryByPids(pids, uid, {stripTags: true}, next);
|
|
||||||
}
|
|
||||||
], callback);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -318,6 +318,9 @@ var async = require('async'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
Topics.getTopicsFields = function(tids, fields, callback) {
|
Topics.getTopicsFields = function(tids, fields, callback) {
|
||||||
|
if (!Array.isArray(tids) || !tids.length) {
|
||||||
|
return callback(null, []);
|
||||||
|
}
|
||||||
var keys = tids.map(function(tid) {
|
var keys = tids.map(function(tid) {
|
||||||
return 'topic:' + tid;
|
return 'topic:' + tid;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ module.exports = function(Topics) {
|
|||||||
tids = tids.slice(start, stop + 1);
|
tids = tids.slice(start, stop + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(err, tids);
|
callback(null, tids);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -115,45 +115,22 @@ module.exports = function(Topics) {
|
|||||||
return callback(null, tids);
|
return callback(null, tids);
|
||||||
}
|
}
|
||||||
|
|
||||||
privileges.topics.filter('read', tids, uid, function(err, tids) {
|
async.waterfall([
|
||||||
if (err || !tids.length) {
|
function(next) {
|
||||||
return callback(err, []);
|
privileges.topics.filter('read', tids, uid, next);
|
||||||
}
|
},
|
||||||
|
function(tids, next) {
|
||||||
var keys = tids.map(function(tid) {
|
Topics.getTopicsFields(tids, ['tid', 'cid'], next);
|
||||||
return 'topic:' + tid;
|
},
|
||||||
});
|
function(topics, next) {
|
||||||
|
tids = topics.filter(function(topic) {
|
||||||
db.getObjectsFields(keys, ['tid', 'cid'], function(err, topics) {
|
return topic && topic.cid && ignoredCids.indexOf(topic.cid.toString()) === -1;
|
||||||
if (err) {
|
|
||||||
return callback(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
var topicCids = topics.filter(function(topic) {
|
|
||||||
return topic && topic.cid;
|
|
||||||
}).map(function(topic) {
|
}).map(function(topic) {
|
||||||
return topic.cid.toString();
|
return topic.tid;
|
||||||
});
|
});
|
||||||
|
next(null, tids);
|
||||||
topicCids = topicCids.filter(function(cid) {
|
}
|
||||||
return ignoredCids.indexOf(cid) === -1;
|
], callback);
|
||||||
});
|
|
||||||
|
|
||||||
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;
|
|
||||||
}).map(function(topic) {
|
|
||||||
return topic.tid;
|
|
||||||
});
|
|
||||||
|
|
||||||
callback(null, topics);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Topics.pushUnreadCount = function(uid, callback) {
|
Topics.pushUnreadCount = function(uid, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user