fix: post indices if there is a blocked user in topic

This commit is contained in:
Barış Soner Uşaklı
2022-01-18 20:31:06 -05:00
parent 3b72ff8742
commit f9279b636b
5 changed files with 9 additions and 6 deletions

View File

@@ -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 [];

View File

@@ -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) {