send invitations emails
This commit is contained in:
@@ -126,12 +126,10 @@ postDB = (DB)=>{
|
||||
profile.following.forEach(element => {
|
||||
following[element] = 1;
|
||||
});
|
||||
console.log(following)
|
||||
for(i in posts){
|
||||
let p = posts[i];
|
||||
let isPostingAPrivateGroup = await DB.isGroupPrivate(p.profileid);
|
||||
let isPostingToAPrivateGroup = p.toProfile ? await DB.isGroupPrivate(p.toProfile) : false;
|
||||
console.log(following[p.profileid], following[p.toProfile + ""], p.toProfile)
|
||||
if(!isPostingAPrivateGroup && !isPostingToAPrivateGroup){
|
||||
filteredPosts.push(p);
|
||||
continue;
|
||||
|
||||
@@ -116,6 +116,27 @@ const youGotANewPostTemplate = (profile, userEmail, senderProfile, message) => {
|
||||
sendEmail(userEmail, subject, html)
|
||||
}
|
||||
|
||||
const youHaveAnInvitation = (invitedName, invitedEmail, senderProfile) => {
|
||||
let subject = senderProfile.profile.firstName + " post on your profile";
|
||||
let html = `
|
||||
<p>Hello ${invitedName},</p>
|
||||
|
||||
<p>You have been invited to be part of the new efforts to be connected through our website.</p>
|
||||
|
||||
<p>The socila part of our site is a place to be in contact with the espiritual family, read what is new for all the members and have access to the most recent teachings, as well as our catalog of courses.</p>
|
||||
|
||||
<p><a href="https://social.emmint.com/">Register to make an account at https://social.emmint.com/</a></p>
|
||||
|
||||
<p> Invitation sent by:
|
||||
${senderProfile.profile.firstName} ${senderProfile.profile.lastName}
|
||||
</p>
|
||||
|
||||
<p>Blessings</p>
|
||||
<p>Emmanuel International Ministries</p>
|
||||
`;
|
||||
sendEmail(invitedEmail, subject, html)
|
||||
}
|
||||
|
||||
const Notifications = {
|
||||
sendEmail,
|
||||
async yourBookmarkedPostGotAComment(post, postProfile, senderProfile, message) {
|
||||
@@ -182,7 +203,8 @@ const Notifications = {
|
||||
const notifBody = `${senderProfile.profile.firstName} post in your profile`;
|
||||
DB.addNotification(toProfileId, notifBody, post._id);
|
||||
return youGotANewPostTemplate(profile, user.username, senderProfile, message);
|
||||
}
|
||||
},
|
||||
youHaveAnInvitation
|
||||
}
|
||||
|
||||
module.exports = Notifications
|
||||
@@ -3,7 +3,7 @@ var router = express.Router()
|
||||
|
||||
const DB = require("./../mongoDB.js");
|
||||
const Post = require("./../def/post.js");
|
||||
const Notifications = require("./../notifications.js")
|
||||
const Notifications = require("./../notifications.js");
|
||||
|
||||
DB.getDB.then((DB)=>{
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ var router = express.Router()
|
||||
|
||||
const DB = require("../mongoDB.js");
|
||||
const Profile = require("../def/profile.js");
|
||||
const Notifications = require("./../notifications.js");
|
||||
|
||||
DB.getDB.then((DB)=>{
|
||||
|
||||
@@ -59,6 +60,8 @@ DB.getDB.then((DB)=>{
|
||||
let r = await DB.newInvitation(userid, name, email);
|
||||
if(!r.toLowerCase){
|
||||
//send email invitation
|
||||
let senderProfile = await DB.getProfile(getProfileId(req));
|
||||
Notifications.youHaveAnInvitation(name, email, senderProfile);
|
||||
return res.json({
|
||||
status: "ok"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user