sending emails when new post to profiles
This commit is contained in:
@@ -3,6 +3,7 @@ var router = express.Router()
|
||||
|
||||
const DB = require("./../mongoDB.js");
|
||||
const Post = require("./../def/post.js");
|
||||
const Notifications = require("./../notifications.js")
|
||||
|
||||
DB.getDB.then((DB)=>{
|
||||
|
||||
@@ -29,9 +30,13 @@ DB.getDB.then((DB)=>{
|
||||
}
|
||||
post.toProfile = post.toProfile ? DB.ObjectID(post.toProfile) : undefined;
|
||||
let postObj = new Post(post);
|
||||
let dbr = await DB.newPost(postObj)
|
||||
let dbr = await DB.newPost(postObj);
|
||||
post = postObj.toObj();
|
||||
post._id = dbr.insertedId;
|
||||
if(post.toProfile && post.toProfile != post.profileid){
|
||||
//send email notification
|
||||
Notifications.youGotANewPost(post.toProfile, post.profileid, post.content)
|
||||
}
|
||||
return res.json({
|
||||
status: "ok",
|
||||
...post
|
||||
|
||||
Reference in New Issue
Block a user