notifications on bookmarks
This commit is contained in:
@@ -22,11 +22,53 @@ const Notifications = {
|
|||||||
|
|
||||||
console.log("Message sent: %s", info.messageId);
|
console.log("Message sent: %s", info.messageId);
|
||||||
},
|
},
|
||||||
|
async yourBookmarkedPostGotAComment(post, whoPostedId, message){
|
||||||
|
const DB = await DBGetter.getDB;
|
||||||
|
let subscribedPromise = post.bookmarks.map((profileid)=>{
|
||||||
|
return DB.getProfileCache(profileid);
|
||||||
|
});
|
||||||
|
let subscribed = await Promise.all(subscribedPromise);
|
||||||
|
let usersPromise = subscribed.map((profile)=>{
|
||||||
|
return DB.getUsernameByIdCache(profile.userid);
|
||||||
|
});
|
||||||
|
let users = await Promise.all(usersPromise);
|
||||||
|
const senderProfile = await DB.getProfileCache(whoPostedId);
|
||||||
|
const postPprofile = await DB.getProfileCache(post.profileid);
|
||||||
|
users.forEach((user, index)=>{
|
||||||
|
let profile = subscribed[index];
|
||||||
|
if(profile._id == senderProfile._id) return 0;
|
||||||
|
let subject = senderProfile.profile.firstName + " commented on the post you follow";
|
||||||
|
let html = `
|
||||||
|
<p>Hello ${profile.profile.firstName},</p>
|
||||||
|
|
||||||
|
<p>One of the post you bookmarked has a new comment:</p>
|
||||||
|
|
||||||
|
<blockquote cite="https://social.emmint.com/">
|
||||||
|
<p>${post.content}</p>
|
||||||
|
</blockquote>
|
||||||
|
<figcaption>— ${postPprofile.profile.firstName} ${postPprofile.profile.lastName}</figcaption>
|
||||||
|
|
||||||
|
<p>Comment:</p>
|
||||||
|
|
||||||
|
<blockquote cite="https://social.emmint.com/">
|
||||||
|
<p>${message}</p>
|
||||||
|
</blockquote>
|
||||||
|
<figcaption>— ${senderProfile.profile.firstName} ${senderProfile.profile.lastName}</figcaption>
|
||||||
|
|
||||||
|
<p><a href="https://social.emmint.com/">Check it on the site</a></p>
|
||||||
|
|
||||||
|
<p>Blessings</p>
|
||||||
|
|
||||||
|
`;
|
||||||
|
this.sendEmail(user, subject, html)
|
||||||
|
})
|
||||||
|
},
|
||||||
async youGotANewPostComment(postId, whoPostedId, message){
|
async youGotANewPostComment(postId, whoPostedId, message){
|
||||||
const DB = await DBGetter.getDB;
|
const DB = await DBGetter.getDB;
|
||||||
const post = await DB.getPost(postId)
|
const post = await DB.getPost(postId)
|
||||||
if(post.bookmarks){
|
if(post.bookmarks){
|
||||||
//send notification to boorkmaked profiles
|
//send notification to boorkmaked profiles
|
||||||
|
this.yourBookmarkedPostGotAComment(post, whoPostedId, message)
|
||||||
}
|
}
|
||||||
const profile = await DB.getProfileCache(post.profileid);
|
const profile = await DB.getProfileCache(post.profileid);
|
||||||
if(profile.isCourse) return 0; //Course owners do not need to receive notifs
|
if(profile.isCourse) return 0; //Course owners do not need to receive notifs
|
||||||
@@ -70,6 +112,7 @@ const Notifications = {
|
|||||||
const senderProfile = await DB.getProfileCache(whoPostedId);
|
const senderProfile = await DB.getProfileCache(whoPostedId);
|
||||||
users.forEach((user, index)=>{
|
users.forEach((user, index)=>{
|
||||||
let profile = subscribed[index];
|
let profile = subscribed[index];
|
||||||
|
if(profile._id == senderProfile._id) return 0;
|
||||||
let subject = senderProfile.profile.firstName + " posted on one of the groups you follow";
|
let subject = senderProfile.profile.firstName + " posted on one of the groups you follow";
|
||||||
let html = `
|
let html = `
|
||||||
<p>Hello ${profile.profile.firstName},</p>
|
<p>Hello ${profile.profile.firstName},</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user