Support ignored restriction reasons from appConfig.
GitOrigin-RevId: 8831b4379764cfd36212083c889449c3d7354114
This commit is contained in:
parent
5b676ca475
commit
57911db0ba
@ -1170,6 +1170,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
||||
vector<tl_object_ptr<telegram_api::jsonObjectValue>> 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<telegram_api::jsonObject *>(config.get())->value_) {
|
||||
Slice key = key_value->key_;
|
||||
@ -1193,6 +1194,29 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (key == "ignore_restriction_reasons") {
|
||||
if (value->get_id() == telegram_api::jsonArray::ID) {
|
||||
auto reasons = std::move(static_cast<telegram_api::jsonArray *>(value)->value_);
|
||||
for (auto &reason : reasons) {
|
||||
if (reason->get_id() == telegram_api::jsonString::ID) {
|
||||
Slice reason_name = static_cast<telegram_api::jsonString *>(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<telegram_api::JSONValue> &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
|
||||
|
@ -20,6 +20,9 @@ string get_restriction_reason_description(const vector<RestrictionReason> &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<RestrictionReason> &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_;
|
||||
}
|
||||
}
|
||||
|
@ -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':
|
||||
|
Reference in New Issue
Block a user