Added liking and security measures

This commit is contained in:
Sven laptop
2026-07-31 15:11:57 +02:00
parent 494b583cbc
commit ab73eecfec
25 changed files with 1095 additions and 91 deletions
+3 -1
View File
@@ -4,18 +4,20 @@ const pool = require("../../db");
const { strictInput } = require("../../middleware/strict_input");
const { authenticateToken } = require("../../middleware/authenticate_token");
const { removeImageLink } = require("../../middleware/post_upload");
const { deletePostNode } = require("./post_graph");
async function delete_post(req, res) {
try {
const id = req.query.id;
const result = await pool.query(
"DELETE FROM posts WHERE id = $1 AND author_id = $2 RETURNING id, image_link",
"UPDATE posts SET active = false WHERE id = $1 AND author_id = $2 RETURNING id, image_link",
[id, req.user.id],
);
if (result.rowCount === 0) {
return res.status(404).send("Post not found or does not belong to you");
}
await removeImageLink(result.rows[0].image_link);
await deletePostNode(result.rows[0].id);
res.status(200).json({
message: "Post Deleted",
});