Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checks for any duplicate post #158

Open
wants to merge 1 commit into
base: PART_1_and_2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion server/controllers/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ export const getPost = async (req, res) => {

export const createPost = async (req, res) => {
const { title, message, selectedFile, creator, tags } = req.body;

const match = await PostMessage({ title, message });

if(match){
return res.status(409).json("duplicate post");
}

const newPostMessage = new PostMessage({ title, message, selectedFile, creator, tags })

Expand Down Expand Up @@ -77,4 +83,4 @@ export const likePost = async (req, res) => {
}


export default router;
export default router;