diff --git a/notifications.js b/notifications.js index fffcbbe..3f07c08 100644 --- a/notifications.js +++ b/notifications.js @@ -395,6 +395,11 @@ const Notifications = { users.forEach((userEmail, index) => { let userProfile = subscribed[index]; //who is this email sending to if (userProfile._id == senderProfile._id) return 0; //avoid sending self notifications + if(groupProfile._id == senderProfile._id){ + const notifBody = `${groupProfile.profile.firstName} ${groupProfile.profile.lastName} has a new post!`; + sendPushNotification(userProfile.token, notifBody, {}); + return DB.addNotification(userProfile._id, notifBody, post._id, null, senderProfile._id); + } const notifBody = `${senderProfile.profile.firstName} post in the group ${groupProfile.profile.firstName} ${groupProfile.profile.lastName}`; sendPushNotification(userProfile.token, notifBody, {}); DB.addNotification(userProfile._id, notifBody, post._id, null, senderProfile._id); @@ -422,6 +427,15 @@ const Notifications = { DB.addNotification(toProfileId, notifBody, post._id, null, senderProfile._id); return youGotANewPostTemplate(profile, user.username, senderProfile, message); }, + async yourGroupMakeANewPost(post) { + const whoPostedId = post.profileid; + const message = post.content; + const DB = await DBGetter.getDB; + const profile = await DB.getProfileCache(whoPostedId); + if (profile.isGroup) { + return this.yourGroupGotANewPost(profile, profile, message, post); + } + }, youHaveAnInvitation, broadcastNews, async yourGroupHasARequest(requesterProfileId, groupId) { diff --git a/routes/post.js b/routes/post.js index 6ee4e83..617e57a 100644 --- a/routes/post.js +++ b/routes/post.js @@ -165,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