restric newsOnly groups from posting
This commit is contained in:
@@ -141,7 +141,9 @@ DB.getDB.then((DB) => {
|
||||
profileid: getProfileId(req),
|
||||
...req.body
|
||||
}
|
||||
if (post.toProfile && await DB.isGroupPrivate(post.toProfile)) {
|
||||
const isGroupPrivate = await DB.isGroupPrivate(post.toProfile);
|
||||
const isGroupNewsOnly = await DB.isGroupNewsOnly(post.toProfile);
|
||||
if (post.toProfile && isGroupPrivate) {
|
||||
let requestProfile = getProfileId(req) + "";
|
||||
let group = await DB.getProfileCache(post.toProfile);
|
||||
if (!group.subscribed[requestProfile] && group._id != requestProfile) {
|
||||
@@ -150,6 +152,11 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
}
|
||||
}
|
||||
if (post.toProfile && isGroupNewsOnly) {
|
||||
return res.json({
|
||||
status: "This is a news only group, only the admin can post",
|
||||
});
|
||||
}
|
||||
post.toProfile = post.toProfile ? DB.ObjectID(post.toProfile) : undefined;
|
||||
let postObj = new Post(post);
|
||||
let dbr = await DB.newPost(postObj);
|
||||
|
||||
Reference in New Issue
Block a user