Skip to content

Commit

Permalink
PollPost.processMultiplePostDataFromOneOwner now sends poll vote to c…
Browse files Browse the repository at this point in the history
…lient
  • Loading branch information
Sebastian-Webster committed Sep 14, 2023
1 parent b974d35 commit 7047997
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion libraries/PollPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ class PollPost {
Upvote.findOne({postId: {$eq: post._id}, postFormat: "Poll", userPublicId: userRequesting.secondId}),
Downvote.findOne({postId: {$eq: post._id}, postFormat: "Poll", userPublicId: userRequesting.secondId}),
]).then(([upvotes, downvotes, isUpvoted, isDownvoted]) => {
let votedFor = "None";
if (post.optionOnesVotes.includes(userRequesting._id)) {
votedFor = "One"
}
if (post.optionTwosVotes.includes(userRequesting._id)) {
votedFor = "Two"
}
if (post.optionThreesVotes.includes(userRequesting._id)) {
votedFor = "Three"
}
if (post.optionFoursVotes.includes(userRequesting._id)) {
votedFor = "Four"
}
if (post.optionFivesVotes.includes(userRequesting._id)) {
votedFor = "Five"
}
if (post.optionSixesVotes.includes(userRequesting._id)) {
votedFor = "Six"
}
const postObject = {
...post,
optionOnesVotes: post.optionOnesVotes.length,
Expand All @@ -32,7 +51,8 @@ class PollPost {
upvoted: !!isUpvoted,
downvoted: !!isDownvoted,
isOwner: postOwner._id.toString() === userRequesting._id.toString(),
interacted: !!isUpvoted || !!isDownvoted
interacted: !!isUpvoted || !!isDownvoted,
votedFor
}

if (isUpvoted) {
Expand Down

0 comments on commit 7047997

Please sign in to comment.