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

From Dev to QA - 12.11.2024 #15

Merged
merged 2 commits into from
Nov 12, 2024
Merged
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
20 changes: 19 additions & 1 deletion backend/src/api/poll-vote/controllers/poll-vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ module.exports = createCoreController(
};

try {
// Check if vote already exist
try{
const findVote = await strapi.entityService.findMany("api::poll-vote.poll-vote",{
filters:{$and:[{
user_id: user?.id
},
{
poll_Id: pollId
}
]}
})
if(findVote?.length >0){
return ctx.badRequest(null, "Poll vote for this user already exist");
}
}
catch(error){
ctx.status = 500;
ctx.body = { error: error, message: error.message };
}
// Create the Poll Vote
try {
pollVote = await strapi.entityService.create(
Expand Down Expand Up @@ -111,7 +130,6 @@ module.exports = createCoreController(
// Global error catch
} catch (error) {
pollVote && (await deletePollVote());

ctx.status = 500;
ctx.body = { error: error, message: error.message };
}
Expand Down
Loading