Skip to content

Node.js based forum software built for the modern web

move modifyPostByPrivilege call before filtering posts so index is correct

Barış Soner Uşaklıacf2f2a77668
diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js
index 918c2cd457..2734e330a9 100644
--- a/src/socket.io/posts.js
+++ b/src/socket.io/posts.js
@@ -159,17 +159,14 @@ SocketPosts.getReplies = function (socket, pid, callback) {
},
function (results, next) {
postPrivileges = results.privileges;
+ results.posts.forEach(function (postData, index) {
+ posts.modifyPostByPrivilege(postData, postPrivileges[index]);
+ });
results.posts = results.posts.filter(function (postData, index) {
return postData && postPrivileges[index].read;
});
topics.addPostData(results.posts, socket.uid, next);
},
- function (postData, next) {
- postData.forEach(function (postData, index) {
- posts.modifyPostByPrivilege(postData, postPrivileges[index]);
- });
- next(null, postData);
- },
], callback);
};