Support MTPROTO_CLUSTER_INVALID error.
This commit is contained in:
parent
08e09160d6
commit
bfcf52f87c
@ -803,7 +803,7 @@ void AuthManager::on_get_authorization(tl_object_ptr<telegram_api::auth_Authoriz
|
|||||||
} else {
|
} else {
|
||||||
td_->set_is_bot_online(true);
|
td_->set_is_bot_online(true);
|
||||||
}
|
}
|
||||||
send_closure(G()->config_manager(), &ConfigManager::request_config);
|
send_closure(G()->config_manager(), &ConfigManager::request_config, false);
|
||||||
if (query_id_ != 0) {
|
if (query_id_ != 0) {
|
||||||
on_query_ok();
|
on_query_ok();
|
||||||
}
|
}
|
||||||
|
@ -909,7 +909,7 @@ void ConfigManager::start_up() {
|
|||||||
|
|
||||||
auto expire_time = load_config_expire_time();
|
auto expire_time = load_config_expire_time();
|
||||||
if (expire_time.is_in_past() || true) {
|
if (expire_time.is_in_past() || true) {
|
||||||
request_config();
|
request_config(false);
|
||||||
} else {
|
} else {
|
||||||
expire_time_ = expire_time;
|
expire_time_ = expire_time;
|
||||||
set_timeout_in(expire_time_.in());
|
set_timeout_in(expire_time_.in());
|
||||||
@ -935,7 +935,7 @@ void ConfigManager::hangup() {
|
|||||||
|
|
||||||
void ConfigManager::loop() {
|
void ConfigManager::loop() {
|
||||||
if (expire_time_ && expire_time_.is_in_past()) {
|
if (expire_time_ && expire_time_.is_in_past()) {
|
||||||
request_config();
|
request_config(reopen_sessions_after_get_config_);
|
||||||
expire_time_ = {};
|
expire_time_ = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -946,17 +946,17 @@ void ConfigManager::try_stop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigManager::request_config() {
|
void ConfigManager::request_config(bool reopen_sessions) {
|
||||||
if (G()->close_flag()) {
|
if (G()->close_flag()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_sent_cnt_ != 0) {
|
if (config_sent_cnt_ != 0 && !reopen_sessions) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_request_flood_control_.add_event(static_cast<int32>(Timestamp::now().at()));
|
lazy_request_flood_control_.add_event(static_cast<int32>(Timestamp::now().at()));
|
||||||
request_config_from_dc_impl(DcId::main());
|
request_config_from_dc_impl(DcId::main(), reopen_sessions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigManager::lazy_request_config() {
|
void ConfigManager::lazy_request_config() {
|
||||||
@ -1086,11 +1086,13 @@ void ConfigManager::on_dc_options_update(DcOptions dc_options) {
|
|||||||
send_closure(config_recoverer_, &ConfigRecoverer::on_dc_options_update, std::move(dc_options));
|
send_closure(config_recoverer_, &ConfigRecoverer::on_dc_options_update, std::move(dc_options));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigManager::request_config_from_dc_impl(DcId dc_id) {
|
void ConfigManager::request_config_from_dc_impl(DcId dc_id, bool reopen_sessions) {
|
||||||
config_sent_cnt_++;
|
config_sent_cnt_++;
|
||||||
|
reopen_sessions_after_get_config_ |= reopen_sessions;
|
||||||
auto query = G()->net_query_creator().create_unauth(telegram_api::help_getConfig(), dc_id);
|
auto query = G()->net_query_creator().create_unauth(telegram_api::help_getConfig(), dc_id);
|
||||||
query->total_timeout_limit_ = 60 * 60 * 24;
|
query->total_timeout_limit_ = 60 * 60 * 24;
|
||||||
G()->net_query_dispatcher().dispatch_with_callback(std::move(query), actor_shared(this, 8));
|
G()->net_query_dispatcher().dispatch_with_callback(std::move(query),
|
||||||
|
actor_shared(this, 8 + static_cast<uint64>(reopen_sessions)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigManager::do_set_ignore_sensitive_content_restrictions(bool ignore_sensitive_content_restrictions) {
|
void ConfigManager::do_set_ignore_sensitive_content_restrictions(bool ignore_sensitive_content_restrictions) {
|
||||||
@ -1257,7 +1259,7 @@ void ConfigManager::on_result(NetQueryPtr res) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK(token == 8);
|
CHECK(token == 8 || token == 9);
|
||||||
CHECK(config_sent_cnt_ > 0);
|
CHECK(config_sent_cnt_ > 0);
|
||||||
config_sent_cnt_--;
|
config_sent_cnt_--;
|
||||||
auto r_config = fetch_result<telegram_api::help_getConfig>(std::move(res));
|
auto r_config = fetch_result<telegram_api::help_getConfig>(std::move(res));
|
||||||
@ -1270,6 +1272,9 @@ void ConfigManager::on_result(NetQueryPtr res) {
|
|||||||
} else {
|
} else {
|
||||||
on_dc_options_update(DcOptions());
|
on_dc_options_update(DcOptions());
|
||||||
process_config(r_config.move_as_ok());
|
process_config(r_config.move_as_ok());
|
||||||
|
if (token == 9) {
|
||||||
|
G()->net_query_dispatcher().update_mtproto_header();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1482,9 +1487,9 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
|||||||
for (auto &key_value : static_cast<telegram_api::jsonObject *>(config.get())->value_) {
|
for (auto &key_value : static_cast<telegram_api::jsonObject *>(config.get())->value_) {
|
||||||
Slice key = key_value->key_;
|
Slice key = key_value->key_;
|
||||||
telegram_api::JSONValue *value = key_value->value_.get();
|
telegram_api::JSONValue *value = key_value->value_.get();
|
||||||
if (key == "test" || key == "wallet_enabled" || key == "wallet_blockchain_name" || key == "wallet_config" ||
|
if (key == "message_animated_emoji_max" || key == "stickers_emoji_cache_time" || key == "test" ||
|
||||||
key == "stickers_emoji_cache_time" || key == "upload_max_fileparts_default" ||
|
key == "upload_max_fileparts_default" || key == "upload_max_fileparts_premium" ||
|
||||||
key == "upload_max_fileparts_premium") {
|
key == "wallet_blockchain_name" || key == "wallet_config" || key == "wallet_enabled") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (key == "ignore_restriction_reasons") {
|
if (key == "ignore_restriction_reasons") {
|
||||||
|
@ -81,7 +81,7 @@ class ConfigManager final : public NetQueryCallback {
|
|||||||
public:
|
public:
|
||||||
explicit ConfigManager(ActorShared<> parent);
|
explicit ConfigManager(ActorShared<> parent);
|
||||||
|
|
||||||
void request_config();
|
void request_config(bool reopen_sessions);
|
||||||
|
|
||||||
void lazy_request_config();
|
void lazy_request_config();
|
||||||
|
|
||||||
@ -108,6 +108,7 @@ class ConfigManager final : public NetQueryCallback {
|
|||||||
private:
|
private:
|
||||||
ActorShared<> parent_;
|
ActorShared<> parent_;
|
||||||
int32 config_sent_cnt_{0};
|
int32 config_sent_cnt_{0};
|
||||||
|
bool reopen_sessions_after_get_config_{false};
|
||||||
ActorOwn<ConfigRecoverer> config_recoverer_;
|
ActorOwn<ConfigRecoverer> config_recoverer_;
|
||||||
int ref_cnt_{1};
|
int ref_cnt_{1};
|
||||||
Timestamp expire_time_;
|
Timestamp expire_time_;
|
||||||
@ -141,7 +142,7 @@ class ConfigManager final : public NetQueryCallback {
|
|||||||
|
|
||||||
void on_result(NetQueryPtr res) final;
|
void on_result(NetQueryPtr res) final;
|
||||||
|
|
||||||
void request_config_from_dc_impl(DcId dc_id);
|
void request_config_from_dc_impl(DcId dc_id, bool reopen_sessions);
|
||||||
void process_config(tl_object_ptr<telegram_api::config> config);
|
void process_config(tl_object_ptr<telegram_api::config> config);
|
||||||
|
|
||||||
void try_request_app_config();
|
void try_request_app_config();
|
||||||
|
@ -284,7 +284,7 @@ void OptionManager::on_option_updated(const string &name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (name == "is_premium") {
|
if (name == "is_premium") {
|
||||||
send_closure(td_->config_manager_, &ConfigManager::request_config);
|
send_closure(td_->config_manager_, &ConfigManager::request_config, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
|
@ -688,7 +688,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const Invoice &invoice)
|
|||||||
<< (invoice.send_email_address_to_provider ? ", sends email address to provider" : "")
|
<< (invoice.send_email_address_to_provider ? ", sends email address to provider" : "")
|
||||||
<< (invoice.recurring_payment_terms_of_service_url.empty()
|
<< (invoice.recurring_payment_terms_of_service_url.empty()
|
||||||
? string()
|
? string()
|
||||||
: ", recurring payments terms of service at " + invoice.recurring_payment_terms_of_service_url)
|
: ", recurring payments terms of service at " +
|
||||||
|
invoice.recurring_payment_terms_of_service_url)
|
||||||
<< " in " << invoice.currency << " with price parts " << format::as_array(invoice.price_parts)
|
<< " in " << invoice.currency << " with price parts " << format::as_array(invoice.price_parts)
|
||||||
<< " and suggested tip amounts " << invoice.suggested_tip_amounts << " up to "
|
<< " and suggested tip amounts " << invoice.suggested_tip_amounts << " up to "
|
||||||
<< invoice.max_tip_amount << "]";
|
<< invoice.max_tip_amount << "]";
|
||||||
|
@ -3199,7 +3199,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateSavedGifs> upda
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateConfig> update, Promise<Unit> &&promise) {
|
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateConfig> update, Promise<Unit> &&promise) {
|
||||||
send_closure(td_->config_manager_, &ConfigManager::request_config);
|
send_closure(td_->config_manager_, &ConfigManager::request_config, false);
|
||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3837,6 +3837,10 @@ void FileManager::on_error_impl(FileNodePtr node, Query::Type type, bool was_act
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (status.message() == "MTPROTO_CLUSTER_INVALID") {
|
||||||
|
run_download(node, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!was_active) {
|
if (!was_active) {
|
||||||
return;
|
return;
|
||||||
|
@ -420,7 +420,7 @@ void ConnectionCreator::set_active_proxy_id(int32 proxy_id, bool from_binlog) {
|
|||||||
if (!from_binlog) {
|
if (!from_binlog) {
|
||||||
if (proxy_id == 0) {
|
if (proxy_id == 0) {
|
||||||
G()->td_db()->get_binlog_pmc()->erase("proxy_active_id");
|
G()->td_db()->get_binlog_pmc()->erase("proxy_active_id");
|
||||||
send_closure(G()->config_manager(), &ConfigManager::request_config);
|
send_closure(G()->config_manager(), &ConfigManager::request_config, false);
|
||||||
} else {
|
} else {
|
||||||
G()->td_db()->get_binlog_pmc()->set("proxy_active_id", to_string(proxy_id));
|
G()->td_db()->get_binlog_pmc()->set("proxy_active_id", to_string(proxy_id));
|
||||||
}
|
}
|
||||||
|
@ -173,6 +173,7 @@ void SessionProxy::close_session() {
|
|||||||
send_closure(std::move(session_), &Session::close);
|
send_closure(std::move(session_), &Session::close);
|
||||||
session_generation_++;
|
session_generation_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionProxy::open_session(bool force) {
|
void SessionProxy::open_session(bool force) {
|
||||||
if (!session_.empty()) {
|
if (!session_.empty()) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user