fix posting on private groups

This commit is contained in:
Adolfo Reyna
2021-09-26 18:29:51 -07:00
parent 7a2b3b9d7b
commit 997d28d702

View File

@@ -35,13 +35,21 @@ DB.getDB.then((DB)=>{
profileid: getProfileId(req),
...req.body
}
if(post.toProfile && await DB.isGroupPrivate(post.toProfile)){
let requestProfile = getProfileId(req) + "";
let group = await DB.getProfileCache(post.toProfile);
if(!group.subscribed[requestProfile] && group._id != requestProfile){
return res.json({
status: "You are not part of this private group",
});
}
}
post.toProfile = post.toProfile ? DB.ObjectID(post.toProfile) : undefined;
let postObj = new Post(post);
let dbr = await DB.newPost(postObj);
post = postObj.toObj();
post._id = dbr.insertedId;
if(post.toProfile && post.toProfile != post.profileid){
//send email notification
Notifications.youGotANewPost(post.toProfile, post.profileid, post.content)
}
return res.json({