From f674110b8a0946fa37afa3098ecba9241403d584 Mon Sep 17 00:00:00 2001 From: tanish35 Date: Wed, 30 Oct 2024 16:51:16 +0530 Subject: [PATCH] Fix cache delete --- backend/src/controllers/postController.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/src/controllers/postController.ts b/backend/src/controllers/postController.ts index 4e8aa13..7175136 100644 --- a/backend/src/controllers/postController.ts +++ b/backend/src/controllers/postController.ts @@ -376,6 +376,8 @@ const createComment = asyncHandler(async (req: Request, res: Response) => { return res.status(404).json({ message: "Post not found" }); } + await deleteCachedPosts(post.College.college_id); + if (post.User.user_id === user_id) { return res.status(201).json({ comment }); } @@ -408,7 +410,7 @@ const createComment = asyncHandler(async (req: Request, res: Response) => { `; sendMail(htmlContent, email, "New Comment on Your Post"); - await deleteCachedPosts(post.College.college_id); + // await deleteCachedPosts(post.College.college_id); return res.status(201).json({ comment }); }); @@ -423,7 +425,7 @@ const deleteComment = asyncHandler(async (req: Request, res: Response) => { user_id: true, }, }, - post_id: true, + post_id: true, }, where: { comment_id: commentId }, }); @@ -450,7 +452,7 @@ const deleteComment = asyncHandler(async (req: Request, res: Response) => { }, where: { post_id: comment.post_id }, }); - if(!collegeId) { + if (!collegeId) { return res.status(404).json({ message: "College not found" }); } await deleteCachedPosts(collegeId.College.college_id);