Regiater only server polls.

GitOrigin-RevId: e6ff1c4d7916a8ce07e45ae95a0458330c4ebcf0
This commit is contained in:
levlam 2019-03-11 15:27:28 +03:00
parent 6da8565b7b
commit 84060b6084
2 changed files with 10 additions and 2 deletions

View File

@ -25196,8 +25196,7 @@ void MessagesManager::set_poll_answer(FullMessageId full_message_id, vector<int3
if (m->content->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<Unit> &&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));
}

View File

@ -485,6 +485,9 @@ PollId PollManager::create_poll(string &&question, vector<string> &&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);