Skip to content

Commit

Permalink
Fix cache delete
Browse files Browse the repository at this point in the history
  • Loading branch information
tanish35 committed Oct 30, 2024
1 parent 09e673e commit f674110
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions backend/src/controllers/postController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down Expand Up @@ -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 });
});
Expand All @@ -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 },
});
Expand All @@ -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);
Expand Down

0 comments on commit f674110

Please sign in to comment.