Node.js based forum software built for the modern web
fix: post indices if there is a blocked user in topic
Barış Soner Uşaklıf9279b636bcf
diff --git a/src/posts/index.js b/src/posts/index.jsindex 43dd6674a6..7b6d3ac787 100644--- a/src/posts/index.js+++ b/src/posts/index.js@@ -45,8 +45,7 @@ Posts.getPostsByPids = async function (pids, uid) {return [];}let posts = await Posts.getPostsData(pids);- posts = await Promise.all(posts.map(p => Posts.parsePost(p)));- posts = await user.blocks.filter(uid, posts);+ posts = await Promise.all(posts.map(Posts.parsePost));const data = await plugins.hooks.fire('filter:post.getPosts', { posts: posts, uid: uid });if (!data || !Array.isArray(data.posts)) {return [];diff --git a/src/posts/topics.js b/src/posts/topics.jsindex 4a467e77ca..9c17d33ba9 100644--- a/src/posts/topics.js+++ b/src/posts/topics.js@@ -2,12 +2,14 @@'use strict';const topics = require('../topics');+const user = require('../user');const utils = require('../utils');module.exports = function (Posts) {Posts.getPostsFromSet = async function (set, start, stop, uid, reverse) {const pids = await Posts.getPidsFromSet(set, start, stop, reverse);- return await Posts.getPostsByPids(pids, uid);+ const posts = await Posts.getPostsByPids(pids, uid);+ return await user.blocks.filter(uid, posts);};Posts.isMain = async function (pids) {diff --git a/src/socket.io/posts.js b/src/socket.io/posts.jsindex 064945c910..322e058935 100644--- a/src/socket.io/posts.js+++ b/src/socket.io/posts.js@@ -98,6 +98,7 @@ SocketPosts.getReplies = async function (socket, pid) {postData = await topics.addPostData(postData, socket.uid);postData.forEach((postData, index) => posts.modifyPostByPrivilege(postData, postPrivileges[index]));postData = postData.filter((postData, index) => postData && postPrivileges[index].read);+ postData = await user.blocks.filter(socket.uid, postData);return postData;};diff --git a/src/topics/index.js b/src/topics/index.jsindex 98e83d14bf..94f9803f5c 100644--- a/src/topics/index.js+++ b/src/topics/index.js@@ -252,7 +252,8 @@ Topics.getMainPosts = async function (tids, uid) {};async function getMainPosts(mainPids, uid) {- const postData = await posts.getPostsByPids(mainPids, uid);+ let postData = await posts.getPostsByPids(mainPids, uid);+ postData = await user.blocks.filter(uid, postData);postData.forEach((post) => {if (post) {post.index = 0;diff --git a/src/topics/posts.js b/src/topics/posts.jsindex 721488b434..5c9e52cdc6 100644--- a/src/topics/posts.js+++ b/src/topics/posts.js@@ -44,7 +44,7 @@ module.exports = function (Topics) {if (topicData.mainPid && start === 0) {pids.unshift(topicData.mainPid);}- const postData = await posts.getPostsByPids(pids, uid);+ let postData = await posts.getPostsByPids(pids, uid);if (!postData.length) {return [];}@@ -55,7 +55,7 @@ module.exports = function (Topics) {}Topics.calculatePostIndices(replies, repliesStart);-+ postData = await user.blocks.filter(uid, postData);await addEventStartEnd(postData, set, reverse, topicData);const result = await plugins.hooks.fire('filter:topic.getPosts', {topic: topicData,