Fix sending response to setPollAnser.

This commit is contained in:
levlam 2020-12-22 01:51:20 +03:00
parent 7d73126506
commit 656a641290
3 changed files with 27 additions and 17 deletions

View File

@ -844,16 +844,19 @@ void PollManager::on_set_poll_answer(PollId poll_id, uint64 generation,
poll->was_saved = false;
}
if (result.is_ok()) {
td_->updates_manager_->on_get_updates(result.move_as_ok(), Promise<Unit>());
for (auto &promise : promises) {
promise.set_value(Unit());
}
td_->updates_manager_->on_get_updates(
result.move_as_ok(), PromiseCreator::lambda([actor_id = actor_id(this), poll_id,
promises = std::move(promises)](Result<Unit> &&result) mutable {
send_closure(actor_id, &PollManager::on_set_poll_answer_finished, poll_id, Unit(), std::move(promises));
}));
} else {
for (auto &promise : promises) {
promise.set_error(result.error().clone());
}
on_set_poll_answer_finished(poll_id, result.move_as_error(), std::move(promises));
}
}
void PollManager::on_set_poll_answer_finished(PollId poll_id, Result<Unit> &&result, vector<Promise<Unit>> &&promises) {
if (!G()->close_flag()) {
auto poll = get_poll(poll_id);
if (poll != nullptr && !poll->was_saved) {
// no updates was sent during updates processing, so send them
// poll wasn't changed, so there is no reason to actually save it
@ -865,6 +868,11 @@ void PollManager::on_set_poll_answer(PollId poll_id, uint64 generation,
notify_on_poll_update(poll_id);
poll->was_saved = true;
}
}
for (auto &promise : promises) {
promise.set_result(result.clone());
}
}
void PollManager::invalidate_poll_voters(const Poll *poll, PollId poll_id) {

View File

@ -186,6 +186,8 @@ class PollManager : public Actor {
void on_set_poll_answer(PollId poll_id, uint64 generation, Result<tl_object_ptr<telegram_api::Updates>> &&result);
void on_set_poll_answer_finished(PollId poll_id, Result<Unit> &&result, vector<Promise<Unit>> &&promises);
void invalidate_poll_voters(const Poll *poll, PollId poll_id);
void invalidate_poll_option_voters(const Poll *poll, PollId poll_id, size_t option_index);

View File

@ -1258,7 +1258,7 @@ void UpdatesManager::on_pending_updates(vector<tl_object_ptr<telegram_api::Updat
return promise.set_value(Unit());
}
if (running_get_difference_) {
if (running_get_difference_ /*|| string(source) != string("postponed updates")*/) {
LOG(INFO) << "Postpone " << updates.size() << " updates [" << seq_begin << ", " << seq_end
<< "] with date = " << date << " from " << source;
postponed_updates_.emplace(seq_begin,