diff --git a/dbTools/post.js b/dbTools/post.js index 46e17af..d6cf297 100644 --- a/dbTools/post.js +++ b/dbTools/post.js @@ -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; diff --git a/notifications.js b/notifications.js index 3c6a047..708823a 100644 --- a/notifications.js +++ b/notifications.js @@ -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 = ` +
Hello ${invitedName},
+ +You have been invited to be part of the new efforts to be connected through our website.
+ +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.
+ +Register to make an account at https://social.emmint.com/
+ +Invitation sent by: +${senderProfile.profile.firstName} ${senderProfile.profile.lastName} +
+ +Blessings
+Emmanuel International Ministries
+`; + 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 \ No newline at end of file diff --git a/routes/post.js b/routes/post.js index 9325c9f..ce6bc43 100644 --- a/routes/post.js +++ b/routes/post.js @@ -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)=>{ diff --git a/routes/profile.js b/routes/profile.js index 17553c6..343d87d 100644 --- a/routes/profile.js +++ b/routes/profile.js @@ -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" });