add update post endpoint
This commit is contained in:
@@ -240,6 +240,21 @@ DB.getDB.then((DB) => {
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/:id", async (req, res) => {
|
||||
const profileid = getProfileId(req) + '';
|
||||
const postId = req.params.id;
|
||||
const post = await DB.getPost(postId);
|
||||
const newContent = req.body.content;
|
||||
if (!postBelongToProfile(post, profileid))
|
||||
return res.json({
|
||||
status: "This post is not yours."
|
||||
});
|
||||
await DB.updatePost(postId, newContent, post.content);
|
||||
return res.json({
|
||||
status: "ok"
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
module.exports = router
|
||||
Reference in New Issue
Block a user