From acf2f2a77668a360790e213c8c988c7e30f2c337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 8 Jun 2018 17:39:17 -0400 Subject: [PATCH] move modifyPostByPrivilege call before filtering posts so index is correct --- src/socket.io/posts.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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); };