From 1f58155cf175adf7cf4518ef0667164e6496466e Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 29 Apr 2020 16:35:53 +0300 Subject: [PATCH] Do not allow revote in a quiz. GitOrigin-RevId: c6865a295b154fee3ba09d96691a7bc86ba4214e --- td/telegram/PollManager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/td/telegram/PollManager.cpp b/td/telegram/PollManager.cpp index cced631e..954e6d0f 100644 --- a/td/telegram/PollManager.cpp +++ b/td/telegram/PollManager.cpp @@ -691,6 +691,9 @@ void PollManager::set_poll_answer(PollId poll_id, FullMessageId full_message_id, if (poll->is_quiz && option_ids.empty()) { return promise.set_error(Status::Error(400, "Can't retract vote in a quiz")); } + if (poll->is_quiz && pending_answers_.count(poll_id) != 0) { + return promise.set_error(Status::Error(400, "Can't revote in a quiz")); + } std::unordered_map affected_option_ids; vector options; @@ -705,6 +708,9 @@ void PollManager::set_poll_answer(PollId poll_id, FullMessageId full_message_id, } for (size_t option_index = 0; option_index < poll->options.size(); option_index++) { if (poll->options[option_index].is_chosen) { + if (poll->is_quiz) { + return promise.set_error(Status::Error(400, "Can't revote in a quiz")); + } affected_option_ids[option_index]++; } }