Fix sending response to setPollAnser.
This commit is contained in:
parent
7d73126506
commit
656a641290
@ -844,26 +844,34 @@ 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
|
||||
if (!(poll->is_closed && poll->is_updated_after_close)) {
|
||||
LOG(INFO) << "Schedule updating of " << poll_id << " soon";
|
||||
update_poll_timeout_.set_timeout_in(poll_id.get(), 0.0);
|
||||
}
|
||||
|
||||
notify_on_poll_update(poll_id);
|
||||
poll->was_saved = true;
|
||||
}
|
||||
}
|
||||
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
|
||||
if (!(poll->is_closed && poll->is_updated_after_close)) {
|
||||
LOG(INFO) << "Schedule updating of " << poll_id << " soon";
|
||||
update_poll_timeout_.set_timeout_in(poll_id.get(), 0.0);
|
||||
}
|
||||
|
||||
notify_on_poll_update(poll_id);
|
||||
poll->was_saved = true;
|
||||
for (auto &promise : promises) {
|
||||
promise.set_result(result.clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user