Notifs for groups posting in feed

This commit is contained in:
Adolfo Reyna
2023-02-07 15:51:37 -05:00
parent af059b6fc6
commit 7ff9223a5c
2 changed files with 15 additions and 0 deletions

View File

@@ -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) {