fix feed to show group posts and filter private groups

This commit is contained in:
Adolfo Reyna
2021-09-29 13:51:16 -07:00
parent 600ec549b4
commit e886b2bd57
2 changed files with 17 additions and 4 deletions

View File

@@ -127,13 +127,26 @@ postDB = (DB)=>{
{profileid: {
$in: ids
}},
//{toProfile: {
// $in: ids
//}}
{toProfile: {
$in: ids
}}
]
};
return DB.postCols.find(query).sort({lastUpdated: -1}).limit(20).toArray().then(async (posts)=>{
//we need to filter when toProfile is private and not part of the following array
let filteredPosts = [];
for(p in posts){
if(!DB.isGroupPrivate(p.profileid) && !DB.isGroupPrivate(p.toProfile)){
filteredPosts.push(p);
}
if(DB.isGroupPrivate(p.profileid) && !profile[p.profileid]){
continue;
}
if(DB.isGroupPrivate(p.toProfile) && !profile[p.toProfile]){
continue;
}
filteredPosts.push(p);
}
return posts;
}).catch((err)=>{
console.log(err);