Fix setting online before setTdlibParameters.

GitOrigin-RevId: f8a1038415100667de798e88fb484d850aa2da32
This commit is contained in:
levlam 2018-09-12 22:51:34 +03:00
parent f7405f8f86
commit 78bd4b0447
2 changed files with 13 additions and 2 deletions

View File

@ -4172,6 +4172,13 @@ Status Td::init(DbKey key) {
web_pages_manager_->on_binlog_web_page_event(std::move(event));
}
if (is_online_) {
if (auth_manager_->is_bot()) {
send_closure(G()->state_manager(), &StateManager::on_online, false);
}
on_online_updated(true, true);
}
// Send binlog events to managers
//
// 1. Actors must receive all binlog events before other queries.
@ -6237,12 +6244,14 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
}
bool is_online = value_constructor_id == td_api::optionValueEmpty::ID ||
static_cast<const td_api::optionValueBoolean *>(request.value_.get())->value_;
if (!auth_manager_->is_bot()) {
if (auth_manager_ == nullptr || !auth_manager_->is_bot()) {
send_closure(G()->state_manager(), &StateManager::on_online, is_online);
}
if (is_online != is_online_) {
is_online_ = is_online;
on_online_updated(true, true);
if (auth_manager_ != nullptr) { // postpone if there is no AuthManager yet
on_online_updated(true, true);
}
}
return send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
}

View File

@ -709,6 +709,8 @@ class CliClient final : public Actor {
"use_pfs", td_api::make_object<td_api::optionValueBoolean>(std::time(nullptr) / 86400 % 2 == 0)));
send_request(td_api::make_object<td_api::setOption>("use_storage_optimizer",
td_api::make_object<td_api::optionValueBoolean>(false)));
send_request(
td_api::make_object<td_api::setOption>("online", td_api::make_object<td_api::optionValueBoolean>(true)));
send_request(td_api::make_object<td_api::setNetworkType>(td_api::make_object<td_api::networkTypeWiFi>()));
send_request(td_api::make_object<td_api::getNetworkStatistics>());