Add data to push notifications
This commit is contained in:
@@ -347,7 +347,7 @@ const Notifications = {
|
|||||||
const bookedProfile = subscribed[index];
|
const bookedProfile = subscribed[index];
|
||||||
if (bookedProfile._id == senderProfile._id) return 0;
|
if (bookedProfile._id == senderProfile._id) return 0;
|
||||||
const notifBody = `${senderProfile.profile.firstName} commented in a post you follow`;
|
const notifBody = `${senderProfile.profile.firstName} commented in a post you follow`;
|
||||||
sendPushNotification(bookedProfile.token, notifBody, {});
|
sendPushNotification(bookedProfile.token, notifBody, {post_id: post._id});
|
||||||
DB.addNotification(bookedProfile._id, notifBody, post._id, post.comments.length - 1, senderProfile._id);
|
DB.addNotification(bookedProfile._id, notifBody, post._id, post.comments.length - 1, senderProfile._id);
|
||||||
yourBookmarkedPostGotACommentTemplate(post, userEmail, postProfile, senderProfile, bookedProfile, message);
|
yourBookmarkedPostGotACommentTemplate(post, userEmail, postProfile, senderProfile, bookedProfile, message);
|
||||||
});
|
});
|
||||||
@@ -363,7 +363,7 @@ const Notifications = {
|
|||||||
}
|
}
|
||||||
if (postProfile.isCourse || senderProfile._id == postProfile._id) return 0; //Course owners do not need to receive notifs
|
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`;
|
const notifBody = `${senderProfile.profile.firstName} commented in your post`;
|
||||||
sendPushNotification(postProfile.token, notifBody, {});
|
sendPushNotification(postProfile.token, notifBody, {post_id: postId, comment: message});
|
||||||
DB.addNotification(post.profileid, notifBody, postId, post.comments.length - 1, senderProfile._id);
|
DB.addNotification(post.profileid, notifBody, postId, post.comments.length - 1, senderProfile._id);
|
||||||
return youGotANewPostCommentTemplate(post, userEmail, postProfile, senderProfile, message);
|
return youGotANewPostCommentTemplate(post, userEmail, postProfile, senderProfile, message);
|
||||||
},
|
},
|
||||||
@@ -376,7 +376,7 @@ const Notifications = {
|
|||||||
subscribed.forEach((bookedProfile) => {
|
subscribed.forEach((bookedProfile) => {
|
||||||
if (bookedProfile._id == senderProfile._id) return 0;
|
if (bookedProfile._id == senderProfile._id) return 0;
|
||||||
const notifBody = `${senderProfile.profile.firstName} liked a post you follow`;
|
const notifBody = `${senderProfile.profile.firstName} liked a post you follow`;
|
||||||
sendPushNotification(bookedProfile.token, notifBody, {});
|
sendPushNotification(bookedProfile.token, notifBody, {post_id: post._id});
|
||||||
DB.addNotification(bookedProfile._id, notifBody, post._id, null, senderProfile._id);
|
DB.addNotification(bookedProfile._id, notifBody, post._id, null, senderProfile._id);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -391,7 +391,7 @@ const Notifications = {
|
|||||||
}
|
}
|
||||||
if (postProfile.isCourse || senderProfile._id == postProfile._id) return 0; //Course owners do not need to receive notifs
|
if (postProfile.isCourse || senderProfile._id == postProfile._id) return 0; //Course owners do not need to receive notifs
|
||||||
const notifBody = `${senderProfile.profile.firstName} liked your post`;
|
const notifBody = `${senderProfile.profile.firstName} liked your post`;
|
||||||
sendPushNotification(postProfile.token, notifBody, {});
|
sendPushNotification(postProfile.token, notifBody, {post_id: post._id});
|
||||||
DB.addNotification(post.profileid, notifBody, postId, null, senderProfile._id);
|
DB.addNotification(post.profileid, notifBody, postId, null, senderProfile._id);
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
@@ -411,11 +411,11 @@ const Notifications = {
|
|||||||
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){
|
if(groupProfile._id == senderProfile._id){
|
||||||
const notifBody = `${groupProfile.profile.firstName} ${groupProfile.profile.lastName} has a new post!`;
|
const notifBody = `${groupProfile.profile.firstName} ${groupProfile.profile.lastName} has a new post!`;
|
||||||
sendPushNotification(userProfile.token, notifBody, {});
|
sendPushNotification(userProfile.token, notifBody, {post_id: post._id, profile_id: groupProfile._id});
|
||||||
return DB.addNotification(userProfile._id, notifBody, post._id, null, senderProfile._id);
|
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, {post_id: post._id, profile_id: groupProfile._id});
|
||||||
DB.addNotification(userProfile._id, notifBody, post._id, null, senderProfile._id);
|
DB.addNotification(userProfile._id, notifBody, post._id, null, senderProfile._id);
|
||||||
// Disabling email notifications for now, until settings are implemented
|
// Disabling email notifications for now, until settings are implemented
|
||||||
// yourGroupGotANewPostTemplate(groupProfile, userEmail, userProfile, senderProfile, message);
|
// yourGroupGotANewPostTemplate(groupProfile, userEmail, userProfile, senderProfile, message);
|
||||||
@@ -437,7 +437,7 @@ const Notifications = {
|
|||||||
return this.broadcastNews(post, emails);
|
return this.broadcastNews(post, emails);
|
||||||
}
|
}
|
||||||
const notifBody = `${senderProfile.profile.firstName} post in your profile`;
|
const notifBody = `${senderProfile.profile.firstName} post in your profile`;
|
||||||
sendPushNotification(profile.token, notifBody, {});
|
sendPushNotification(profile.token, notifBody, {post_id: post._id, profile_id: post.profileid});
|
||||||
// sendWebNotification(profile.webSubscription, notifBody, message);
|
// sendWebNotification(profile.webSubscription, notifBody, message);
|
||||||
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);
|
||||||
@@ -461,7 +461,7 @@ const Notifications = {
|
|||||||
const userProfile = subscribed_profiles[index];
|
const userProfile = subscribed_profiles[index];
|
||||||
if (userProfile._id == whoPostedId._id) return 0;
|
if (userProfile._id == whoPostedId._id) return 0;
|
||||||
const notifBody = `${profile.profile.firstName} posted: ${message.substring(0, 50)}...`;
|
const notifBody = `${profile.profile.firstName} posted: ${message.substring(0, 50)}...`;
|
||||||
sendPushNotification(userProfile.token, notifBody, {});
|
sendPushNotification(userProfile.token, notifBody, {profile_id: whoPostedId});
|
||||||
//sendWebNotification(userProfile.webSubscription, notifBody, message);
|
//sendWebNotification(userProfile.webSubscription, notifBody, message);
|
||||||
DB.addNotification(userProfile._id, notifBody, post._id, null, profile._id);
|
DB.addNotification(userProfile._id, notifBody, post._id, null, profile._id);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user