Notifs for groups posting in feed
This commit is contained in:
@@ -395,6 +395,11 @@ const Notifications = {
|
|||||||
users.forEach((userEmail, index) => {
|
users.forEach((userEmail, index) => {
|
||||||
let userProfile = subscribed[index]; //who is this email sending to
|
let userProfile = subscribed[index]; //who is this email sending to
|
||||||
if (userProfile._id == senderProfile._id) return 0; //avoid sending self notifications
|
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}`;
|
const notifBody = `${senderProfile.profile.firstName} post in the group ${groupProfile.profile.firstName} ${groupProfile.profile.lastName}`;
|
||||||
sendPushNotification(userProfile.token, notifBody, {});
|
sendPushNotification(userProfile.token, notifBody, {});
|
||||||
DB.addNotification(userProfile._id, notifBody, post._id, null, senderProfile._id);
|
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);
|
DB.addNotification(toProfileId, notifBody, post._id, null, senderProfile._id);
|
||||||
return youGotANewPostTemplate(profile, user.username, senderProfile, message);
|
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,
|
youHaveAnInvitation,
|
||||||
broadcastNews,
|
broadcastNews,
|
||||||
async yourGroupHasARequest(requesterProfileId, groupId) {
|
async yourGroupHasARequest(requesterProfileId, groupId) {
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ DB.getDB.then((DB) => {
|
|||||||
if ((post.toProfile && post.toProfile != post.profileid) || post.nonOrganicType == 'News') {
|
if ((post.toProfile && post.toProfile != post.profileid) || post.nonOrganicType == 'News') {
|
||||||
Notifications.youGotANewPost(post);
|
Notifications.youGotANewPost(post);
|
||||||
}
|
}
|
||||||
|
Notifications.yourGroupGotANewPost(post);
|
||||||
return res.json({
|
return res.json({
|
||||||
status: "ok",
|
status: "ok",
|
||||||
...post
|
...post
|
||||||
|
|||||||
Reference in New Issue
Block a user