|
|
@ -122,23 +122,32 @@ SocketPosts.getReplies = function (socket, pid, callback) {
|
|
|
|
if (!utils.isNumber(pid)) {
|
|
|
|
if (!utils.isNumber(pid)) {
|
|
|
|
return callback(new Error('[[error:invalid-data]'));
|
|
|
|
return callback(new Error('[[error:invalid-data]'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var postPrivileges;
|
|
|
|
async.waterfall([
|
|
|
|
async.waterfall([
|
|
|
|
function (next) {
|
|
|
|
function (next) {
|
|
|
|
posts.getPidsFromSet('pid:' + pid + ':replies', 0, -1, false, next);
|
|
|
|
posts.getPidsFromSet('pid:' + pid + ':replies', 0, -1, false, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (pids, next) {
|
|
|
|
function (pids, next) {
|
|
|
|
privileges.posts.filter('read', pids, socket.uid, next);
|
|
|
|
async.parallel({
|
|
|
|
|
|
|
|
posts: function (next) {
|
|
|
|
|
|
|
|
posts.getPostsByPids(pids, socket.uid, next);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
privileges: function (next) {
|
|
|
|
|
|
|
|
privileges.posts.get(pids, socket.uid, next);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (pids, next) {
|
|
|
|
function (results, next) {
|
|
|
|
posts.getPostsByPids(pids, socket.uid, next);
|
|
|
|
postPrivileges = results.privileges;
|
|
|
|
}
|
|
|
|
topics.addPostData(results.posts, socket.uid, next);
|
|
|
|
], function (err, postData) {
|
|
|
|
},
|
|
|
|
if (err) {
|
|
|
|
function (postData, next) {
|
|
|
|
return callback(err);
|
|
|
|
postData.forEach(function (postData) {
|
|
|
|
|
|
|
|
posts.modifyPostByPrivilege(postData, postPrivileges.isAdminOrMod);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
next(null, postData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
], callback);
|
|
|
|
topics.addPostData(postData, socket.uid, callback);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|