This commit is contained in:
Adolfo Reyna
2023-07-08 16:36:46 -04:00
3 changed files with 30 additions and 1 deletions

View File

@@ -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);
@@ -158,6 +165,7 @@ DB.getDB.then((DB) => {
if ((post.toProfile && post.toProfile != post.profileid) || post.nonOrganicType == 'News') {
Notifications.youGotANewPost(post);
}
Notifications.yourGroupGotANewPost(post);
return res.json({
status: "ok",
...post