bookmarks in progress missing notifications
This commit is contained in:
@@ -41,6 +41,32 @@ postDB = (DB)=>{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB.bookmarkPost = async (postid, profileId)=>{
|
||||||
|
const _id = DB.ObjectID(postid);
|
||||||
|
let update = {
|
||||||
|
$addToSet:{
|
||||||
|
bookmarks: DB.ObjectID(profileId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DB.postCols.updateOne({_id}, update).catch((err)=>{
|
||||||
|
console.log(err);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
DB.unbookmarkPost = async (postid, profileId)=>{
|
||||||
|
const _id = DB.ObjectID(postid);
|
||||||
|
let update = {
|
||||||
|
$pull:{
|
||||||
|
bookmarks: DB.ObjectID(profileId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DB.postCols.updateOne({_id}, update).catch((err)=>{
|
||||||
|
console.log(err);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
DB.newComment = (postid, comment) => {
|
DB.newComment = (postid, comment) => {
|
||||||
const id = DB.ObjectID(postid);
|
const id = DB.ObjectID(postid);
|
||||||
return DB.postCols.updateOne({_id: id}, {
|
return DB.postCols.updateOne({_id: id}, {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class Post {
|
|||||||
this.createdAt = info.createdAt || new Date();
|
this.createdAt = info.createdAt || new Date();
|
||||||
this.reactions = info.reactions || {};
|
this.reactions = info.reactions || {};
|
||||||
this.comments = info.comments || [];
|
this.comments = info.comments || [];
|
||||||
|
this.bookmarks = info.bookmarks || []; //set profiles subscribed to this post
|
||||||
//This should record edits
|
//This should record edits
|
||||||
this.contentHistory = info.contentHistory || [];
|
this.contentHistory = info.contentHistory || [];
|
||||||
this.toProfile = info.toProfile || '';
|
this.toProfile = info.toProfile || '';
|
||||||
|
|||||||
@@ -25,7 +25,11 @@ const Notifications = {
|
|||||||
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){
|
||||||
|
//send notification to boorkmaked profiles
|
||||||
|
}
|
||||||
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
|
||||||
const user = await DB.getUserById(profile.userid);
|
const user = await DB.getUserById(profile.userid);
|
||||||
const senderProfile = await DB.getProfileCache(whoPostedId);
|
const senderProfile = await DB.getProfileCache(whoPostedId);
|
||||||
let subject = senderProfile.profile.firstName + " comment on your post";
|
let subject = senderProfile.profile.firstName + " comment on your post";
|
||||||
|
|||||||
@@ -44,23 +44,40 @@ DB.getDB.then((DB)=>{
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.post("/react", async (req, res) => {
|
router.post("/react", async (req, res) => {
|
||||||
let userid = getProfileId(req);
|
let profileid = getProfileId(req);
|
||||||
let postid = req.body.postid;
|
let postid = req.body.postid;
|
||||||
let reaction = {
|
let reaction = {
|
||||||
type: "like",
|
type: "like",
|
||||||
createdAt: new Date()
|
createdAt: new Date()
|
||||||
};
|
};
|
||||||
r = await DB.newReaction(postid, userid, reaction);
|
r = await DB.newReaction(postid, profileid, reaction);
|
||||||
return res.json({
|
return res.json({
|
||||||
status: "ok"
|
status: "ok"
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
router.post("/unreact", async (req, res) => {
|
router.post("/unreact", async (req, res) => {
|
||||||
let userid = getProfileId(req);
|
let profileid = getProfileId(req);
|
||||||
let postid = req.body.postid;
|
let postid = req.body.postid;
|
||||||
r = await DB.removeReaction(postid, userid);
|
r = await DB.removeReaction(postid, profileid);
|
||||||
console.log(r)
|
return res.json({
|
||||||
|
status: "ok"
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
router.post("/bookmark", async (req, res) => {
|
||||||
|
let profileid = getProfileId(req);
|
||||||
|
let postid = req.body.postid;
|
||||||
|
r = await DB.bookmarkPost(postid, profileid);
|
||||||
|
return res.json({
|
||||||
|
status: "ok"
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
router.post("/unbookmark", async (req, res) => {
|
||||||
|
let profileid = getProfileId(req);
|
||||||
|
let postid = req.body.postid;
|
||||||
|
r = await DB.unbookmarkPost(postid, profileid);
|
||||||
return res.json({
|
return res.json({
|
||||||
status: "ok"
|
status: "ok"
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user