Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(polls): Avoid duplicating voters.
damencho7d17db63b5bc
diff --git a/resources/prosody-plugins/mod_polls_component.lua b/resources/prosody-plugins/mod_polls_component.luaindex bb20fcd82d..3d2a43bdd3 100644--- a/resources/prosody-plugins/mod_polls_component.lua+++ b/resources/prosody-plugins/mod_polls_component.lua@@ -281,6 +281,46 @@ endlocal voter = occupant_details;+ -- Capture the voter's current vote state so we can detect changes.+ local previous_answers = {};+ for idx, answer in ipairs(poll.answers) do+ previous_answers[idx] = false;+ if answer.voters then+ for _, v in ipairs(answer.voters) do+ if v.id == voter.occupant_id then+ previous_answers[idx] = true;+ break;+ end+ end+ end+ end++ -- Skip processing if the vote is identical to the previous one.+ local vote_changed = false;+ for idx, vote_flag in ipairs(data.answers) do+ if previous_answers[idx] ~= vote_flag then+ vote_changed = true;+ break;+ end+ end+ if not vote_changed then+ return true;+ end++ -- Remove any previous votes by this voter before recording new ones,+ -- preventing duplicate votes for the same option.+ for _, answer in ipairs(poll.answers) do+ if answer.voters then+ local filtered = {};+ for _, v in ipairs(answer.voters) do+ if v.id ~= voter.occupant_id then+ table.insert(filtered, v);+ end+ end+ answer.voters = filtered;+ end+ end+local answers = {};for vote_option_idx, vote_flag in ipairs(data.answers) dolocal answer = poll.answers[vote_option_idx]