diff --git a/td/telegram/PollManager.cpp b/td/telegram/PollManager.cpp index c71acf815..cc1f3e1cd 100644 --- a/td/telegram/PollManager.cpp +++ b/td/telegram/PollManager.cpp @@ -85,11 +85,11 @@ class GetPollResultsQuery : public Td::ResultHandler { }; class SetPollAnswerActor : public NetActorOnce { - Promise promise_; + Promise> promise_; DialogId dialog_id_; public: - explicit SetPollAnswerActor(Promise &&promise) : promise_(std::move(promise)) { + explicit SetPollAnswerActor(Promise> &&promise) : promise_(std::move(promise)) { } void send(FullMessageId full_message_id, vector &&options, uint64 generation, NetQueryRef *query_ref) { @@ -117,9 +117,7 @@ class SetPollAnswerActor : public NetActorOnce { auto result = result_ptr.move_as_ok(); LOG(INFO) << "Receive sendVote result: " << to_string(result); - - td->updates_manager_->on_get_updates(std::move(result)); - promise_.set_value(Unit()); + promise_.set_value(std::move(result)); } void on_error(uint64 id, Status status) override { @@ -447,7 +445,8 @@ td_api::object_ptr PollManager::get_poll_object(PollId poll_id) co auto voter_counts = transform(poll_options, [](auto &poll_option) { return poll_option->voter_count_; }); for (auto &voter_count : voter_counts) { if (total_voter_count < voter_count) { - LOG(ERROR) << "Fix total voter count from " << total_voter_count << " to " << voter_count; + LOG(ERROR) << "Fix total voter count from " << poll->total_voter_count << " + " << voter_count_diff << " to " + << voter_count; total_voter_count = voter_count; } } @@ -631,14 +630,16 @@ void PollManager::do_set_poll_answer(PollId poll_id, FullMessageId full_message_ notify_on_poll_update(poll_id); - auto query_promise = PromiseCreator::lambda([poll_id, generation, actor_id = actor_id(this)](Result &&result) { - send_closure(actor_id, &PollManager::on_set_poll_answer, poll_id, generation, std::move(result)); - }); + auto query_promise = PromiseCreator::lambda( + [poll_id, generation, actor_id = actor_id(this)](Result> &&result) { + send_closure(actor_id, &PollManager::on_set_poll_answer, poll_id, generation, std::move(result)); + }); send_closure(td_->create_net_actor(std::move(query_promise)), &SetPollAnswerActor::send, full_message_id, std::move(sent_options), generation, &pending_answer.query_ref_); } -void PollManager::on_set_poll_answer(PollId poll_id, uint64 generation, Result &&result) { +void PollManager::on_set_poll_answer(PollId poll_id, uint64 generation, + Result> &&result) { if (G()->close_flag() && result.is_error()) { // request will be re-sent after restart return; @@ -661,6 +662,10 @@ void PollManager::on_set_poll_answer(PollId poll_id, uint64 generation, Resultupdates_manager_->on_get_updates(result.move_as_ok()); + for (auto &promise : promises) { if (result.is_ok()) { promise.set_value(Unit()); @@ -668,8 +673,6 @@ void PollManager::on_set_poll_answer(PollId poll_id, uint64 generation, Result &&promise) { diff --git a/td/telegram/PollManager.h b/td/telegram/PollManager.h index 3bb6148a7..3d6f60539 100644 --- a/td/telegram/PollManager.h +++ b/td/telegram/PollManager.h @@ -142,7 +142,7 @@ class PollManager : public Actor { void do_set_poll_answer(PollId poll_id, FullMessageId full_message_id, vector &&options, uint64 logevent_id, Promise &&promise); - void on_set_poll_answer(PollId poll_id, uint64 generation, Result &&result); + void on_set_poll_answer(PollId poll_id, uint64 generation, Result> &&result); void do_stop_poll(PollId poll_id, FullMessageId full_message_id, uint64 logevent_id, Promise &&promise);