diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index 8114f828..651da656 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -1170,6 +1170,7 @@ void ConfigManager::process_app_config(tl_object_ptr &c vector> new_values; string wallet_blockchain_name; string wallet_config; + string ignored_restriction_reasons; if (config->get_id() == telegram_api::jsonObject::ID) { for (auto &key_value : static_cast(config.get())->value_) { Slice key = key_value->key_; @@ -1193,6 +1194,29 @@ void ConfigManager::process_app_config(tl_object_ptr &c } continue; } + if (key == "ignore_restriction_reasons") { + if (value->get_id() == telegram_api::jsonArray::ID) { + auto reasons = std::move(static_cast(value)->value_); + for (auto &reason : reasons) { + if (reason->get_id() == telegram_api::jsonString::ID) { + Slice reason_name = static_cast(reason.get())->value_; + if (!reason_name.empty() && reason_name.find(',') == Slice::npos) { + if (!ignored_restriction_reasons.empty()) { + ignored_restriction_reasons += ','; + } + ignored_restriction_reasons.append(reason_name.begin(), reason_name.end()); + } else { + LOG(ERROR) << "Receive unexpected restriction reason " << reason_name; + } + } else { + LOG(ERROR) << "Receive unexpected restriction reason " << to_string(reason); + } + } + } else { + LOG(ERROR) << "Receive unexpected ignore_restriction_reasons " << to_string(*value); + } + continue; + } new_values.push_back(std::move(key_value)); } @@ -1209,6 +1233,11 @@ void ConfigManager::process_app_config(tl_object_ptr &c shared_config.set_option_string("default_ton_blockchain_name", wallet_blockchain_name); shared_config.set_option_string("default_ton_blockchain_config", wallet_config); } + if (ignored_restriction_reasons.empty()) { + shared_config.set_option_empty("ignored_restriction_reasons"); + } else { + shared_config.set_option_string("ignored_restriction_reasons", ignored_restriction_reasons); + } } } // namespace td diff --git a/td/telegram/RestrictionReason.cpp b/td/telegram/RestrictionReason.cpp index 081bd4b8..3693e10f 100644 --- a/td/telegram/RestrictionReason.cpp +++ b/td/telegram/RestrictionReason.cpp @@ -20,6 +20,9 @@ string get_restriction_reason_description(const vector &restr if (restriction_reasons.empty()) { return string(); } + + auto ignored_restriction_reasons = + full_split(G()->shared_config().get_option_string("ignored_restriction_reasons"), ','); auto platform = [] { if (G()->shared_config().get_option_boolean("ignore_platform_restrictions")) { return Slice(); @@ -38,14 +41,16 @@ string get_restriction_reason_description(const vector &restr if (!platform.empty()) { for (auto &restriction_reason : restriction_reasons) { - if (restriction_reason.platform_ == platform) { + if (restriction_reason.platform_ == platform && + !td::contains(ignored_restriction_reasons, restriction_reason.reason_)) { return restriction_reason.description_; } } } for (auto &restriction_reason : restriction_reasons) { - if (restriction_reason.platform_ == "all") { + if (restriction_reason.platform_ == "all" && + !td::contains(ignored_restriction_reasons, restriction_reason.reason_)) { return restriction_reason.description_; } } diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 0e10e0c2..6975ee73 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -3789,6 +3789,8 @@ bool Td::is_internal_config_option(Slice name) { return name == "dc_txt_domain_name"; case 'e': return name == "edit_time_limit"; + case 'i': + return name == "ignored_restriction_reasons"; case 'l': return name == "language_pack_version"; case 'm':