From 84060b608495fb4c4a51deab416616614ce73eb4 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 11 Mar 2019 15:27:28 +0300 Subject: [PATCH] Regiater only server polls. GitOrigin-RevId: e6ff1c4d7916a8ce07e45ae95a0458330c4ebcf0 --- td/telegram/MessagesManager.cpp | 6 ++++-- td/telegram/PollManager.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 7b8c222db..a269674b3 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -25196,8 +25196,7 @@ void MessagesManager::set_poll_answer(FullMessageId full_message_id, vectorcontent->get_type() != MessageContentType::Poll) { return promise.set_error(Status::Error(5, "Message is not a poll")); } - auto message_id = full_message_id.get_message_id(); - if (!message_id.is_server()) { + if (!full_message_id.get_message_id().is_server()) { return promise.set_error(Status::Error(5, "Poll can't be answered")); } @@ -25218,6 +25217,9 @@ void MessagesManager::stop_poll(FullMessageId full_message_id, Promise &&p if (!can_edit_message(full_message_id.get_dialog_id(), m, true)) { return promise.set_error(Status::Error(5, "Poll can't be stopped")); } + if (!full_message_id.get_message_id().is_server()) { + return promise.set_error(Status::Error(5, "Poll can't be stopped")); + } stop_message_content_poll(td_, m->content.get(), full_message_id, std::move(promise)); } diff --git a/td/telegram/PollManager.cpp b/td/telegram/PollManager.cpp index 2235a54bb..c71acf815 100644 --- a/td/telegram/PollManager.cpp +++ b/td/telegram/PollManager.cpp @@ -485,6 +485,9 @@ PollId PollManager::create_poll(string &&question, vector &&options) { void PollManager::register_poll(PollId poll_id, FullMessageId full_message_id) { CHECK(have_poll(poll_id)); + if (!full_message_id.get_message_id().is_server()) { + return; + } LOG(INFO) << "Register " << poll_id << " from " << full_message_id; bool is_inserted = poll_messages_[poll_id].insert(full_message_id).second; CHECK(is_inserted); @@ -495,6 +498,9 @@ void PollManager::register_poll(PollId poll_id, FullMessageId full_message_id) { void PollManager::unregister_poll(PollId poll_id, FullMessageId full_message_id) { CHECK(have_poll(poll_id)); + if (!full_message_id.get_message_id().is_server()) { + return; + } LOG(INFO) << "Unregister " << poll_id << " from " << full_message_id; auto &message_ids = poll_messages_[poll_id]; auto is_deleted = message_ids.erase(full_message_id);