mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2026-03-10 13:15:05 +00:00
saved states of post for each user
This commit is contained in:
@@ -160,6 +160,24 @@ exports.quoteWithoutPost = (req, res) => {
|
||||
|
||||
}
|
||||
|
||||
exports.checkforLikePost = (req, res) => {
|
||||
const likedPostDoc = admin.firestore().collection('likes').where('userHandle', '==', req.user.handle)
|
||||
.where('postId', '==', req.params.postId).limit(1);
|
||||
let result;
|
||||
|
||||
likedPostDoc.get()
|
||||
.then((data) => {
|
||||
if (data.empty) {
|
||||
result = false;
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
exports.likePost = (req, res) => {
|
||||
let postData;
|
||||
@@ -201,6 +219,7 @@ exports.likePost = (req, res) => {
|
||||
|
||||
}
|
||||
|
||||
|
||||
exports.unlikePost = (req, res) => {
|
||||
|
||||
let postData;
|
||||
|
||||
@@ -70,7 +70,7 @@ app.post("/removeSub", fbAuth, removeSub);
|
||||
/*------------------------------------------------------------------*
|
||||
* handlers/post.js *
|
||||
*------------------------------------------------------------------*/
|
||||
const { getallPostsforUser, getallPosts, putPost, likePost, unlikePost, quoteWithPost, quoteWithoutPost} = require("./handlers/post");
|
||||
const { getallPostsforUser, getallPosts, putPost, likePost, unlikePost, quoteWithPost, quoteWithoutPost, checkforLikePost} = require("./handlers/post");
|
||||
|
||||
app.get("/getallPostsforUser", fbAuth, getallPostsforUser);
|
||||
|
||||
@@ -81,6 +81,7 @@ app.post("/putPost", fbAuth, putPost);
|
||||
|
||||
app.get("/like/:postId", fbAuth, likePost);
|
||||
app.get("/unlike/:postId", fbAuth, unlikePost);
|
||||
app.get("/checkforLikePost/:postId", fbAuth, checkforLikePost);
|
||||
|
||||
app.post("/quoteWithPost/:postId", fbAuth, quoteWithPost);
|
||||
app.post("/quoteWithoutPost/:postId", fbAuth, quoteWithoutPost);
|
||||
|
||||
Reference in New Issue
Block a user