internal notifications
This commit is contained in:
@@ -131,6 +131,8 @@ const Notifications = {
|
||||
usersEmails.forEach((userEmail, index) => {
|
||||
const bookedProfile = subscribed[index];
|
||||
if (bookedProfile._id == senderProfile._id) return 0;
|
||||
const notifBody = `${senderProfile.profile.firstName} commented in a post you follow`;
|
||||
DB.addNotification(bookedProfile._id, notifBody, post._id, post.comments.length - 1);
|
||||
yourBookmarkedPostGotACommentTemplate(post, userEmail, postProfile, senderProfile, bookedProfile, message);
|
||||
});
|
||||
},
|
||||
@@ -144,6 +146,8 @@ const Notifications = {
|
||||
this.yourBookmarkedPostGotAComment(post, postProfile, senderProfile, message)
|
||||
}
|
||||
if (postProfile.isCourse || senderProfile._id == postProfile._id) return 0; //Course owners do not need to receive notifs
|
||||
const notifBody = `${senderProfile.profile.firstName} commented in your post`;
|
||||
DB.addNotification(post.profileid, notifBody, postId, post.comments.length - 1);
|
||||
return youGotANewPostCommentTemplate(post, userEmail, postProfile, senderProfile, message);
|
||||
},
|
||||
async yourGroupGotANewPost(groupProfile, senderProfile, message) {
|
||||
@@ -159,10 +163,15 @@ 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
|
||||
const notifBody = `${senderProfile.profile.firstName} post in the group ${groupProfile.profile.firstName} ${groupProfile.profile.lastName}`;
|
||||
DB.addNotification(userProfile._id, notifBody, post._id);
|
||||
yourGroupGotANewPostTemplate(groupProfile, userEmail, userProfile, senderProfile, message);
|
||||
});
|
||||
},
|
||||
async youGotANewPost(toProfileId, whoPostedId, message) {
|
||||
async youGotANewPost(post) {
|
||||
const toProfileId = post.toProfile;
|
||||
const whoPostedId = post.profileid;
|
||||
const message = post.content;
|
||||
const DB = await DBGetter.getDB;
|
||||
const profile = await DB.getProfileCache(toProfileId);
|
||||
const user = await DB.getUserById(profile.userid);
|
||||
@@ -170,6 +179,8 @@ const Notifications = {
|
||||
if (profile.isGroup) {
|
||||
return this.yourGroupGotANewPost(profile, senderProfile, message);
|
||||
}
|
||||
const notifBody = `${senderProfile.profile.firstName} post in your profile`;
|
||||
DB.addNotification(toProfileId, notifBody, post._id);
|
||||
return youGotANewPostTemplate(profile, user.username, senderProfile, message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user