fix feed to show group posts and filter private groups
This commit is contained in:
@@ -127,13 +127,26 @@ postDB = (DB)=>{
|
|||||||
{profileid: {
|
{profileid: {
|
||||||
$in: ids
|
$in: ids
|
||||||
}},
|
}},
|
||||||
//{toProfile: {
|
{toProfile: {
|
||||||
// $in: ids
|
$in: ids
|
||||||
//}}
|
}}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
return DB.postCols.find(query).sort({lastUpdated: -1}).limit(20).toArray().then(async (posts)=>{
|
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
|
//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;
|
return posts;
|
||||||
}).catch((err)=>{
|
}).catch((err)=>{
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ userDB = (DB) => {
|
|||||||
DB.isGroupPrivate = async (groupid) => {
|
DB.isGroupPrivate = async (groupid) => {
|
||||||
if(userProfileCache[groupid]) return userProfileCache[groupid].isPrivate;
|
if(userProfileCache[groupid]) return userProfileCache[groupid].isPrivate;
|
||||||
let g = await DB.getGroup(groupid);
|
let g = await DB.getGroup(groupid);
|
||||||
return g.isPrivate;
|
return g ? g.isPrivate : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DB.getGroup = async (groupid) => {
|
DB.getGroup = async (groupid) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user