From 38de2b016ebc9d21f1a533762b9f8e25ebe33785 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 19 Apr 2020 11:27:40 +0300 Subject: [PATCH] Never drop correct poll option and quiz explanation. GitOrigin-RevId: 5cd600cd0bb1a5c4200eb74d62ace5da6425ca7d --- td/telegram/PollManager.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/td/telegram/PollManager.cpp b/td/telegram/PollManager.cpp index de4dfedf6..8265f281a 100644 --- a/td/telegram/PollManager.cpp +++ b/td/telegram/PollManager.cpp @@ -1478,17 +1478,29 @@ PollId PollManager::on_get_poll(PollId poll_id, tl_object_ptris_quiz) { if (poll->correct_option_id != correct_option_id) { - poll->correct_option_id = correct_option_id; - is_changed = true; + if (correct_option_id == -1 && poll->correct_option_id != -1) { + LOG(ERROR) << "Can't change correct option of " << poll_id << " from " << poll->correct_option_id << " to " + << correct_option_id; + } else { + poll->correct_option_id = correct_option_id; + is_changed = true; + } } if (poll->explanation != explanation && (!is_min || poll->is_closed)) { - poll->explanation = std::move(explanation); - is_changed = true; + if (explanation.text.empty() && !poll->explanation.text.empty()) { + LOG(ERROR) << "Can't change known " << poll_id << " explanation to empty"; + } else { + poll->explanation = std::move(explanation); + is_changed = true; + } } } else { if (correct_option_id != -1) { LOG(ERROR) << "Receive correct option " << correct_option_id << " in non-quiz " << poll_id; } + if (!explanation.text.empty()) { + LOG(ERROR) << "Receive explanation " << explanation << " in non-quiz " << poll_id; + } } vector recent_voter_user_ids;