fix feed to show group posts and filter private groups
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -148,7 +148,7 @@ userDB = (DB) => {
|
||||
DB.isGroupPrivate = async (groupid) => {
|
||||
if(userProfileCache[groupid]) return userProfileCache[groupid].isPrivate;
|
||||
let g = await DB.getGroup(groupid);
|
||||
return g.isPrivate;
|
||||
return g ? g.isPrivate : false;
|
||||
}
|
||||
|
||||
DB.getGroup = async (groupid) => {
|
||||
|
||||
Reference in New Issue
Block a user