diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index 36d5affd2..1b3888166 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -1471,6 +1471,7 @@ void ConfigManager::process_app_config(tl_object_ptr &c vector> new_values; string ignored_restriction_reasons; + string restriction_add_platforms; vector dice_emojis; FlatHashMap dice_emoji_index; FlatHashMap dice_emoji_success_value; @@ -1519,6 +1520,25 @@ void ConfigManager::process_app_config(tl_object_ptr &c } continue; } + if (key == "restriction_add_platforms") { + if (value->get_id() == telegram_api::jsonArray::ID) { + auto platforms = std::move(static_cast(value)->value_); + for (auto &platform : platforms) { + auto platform_name = get_json_value_string(std::move(platform), key); + if (!platform_name.empty() && platform_name.find(',') == string::npos) { + if (!restriction_add_platforms.empty()) { + restriction_add_platforms += ','; + } + restriction_add_platforms += platform_name; + } else { + LOG(ERROR) << "Receive unexpected restriction platform " << platform_name; + } + } + } else { + LOG(ERROR) << "Receive unexpected restriction_add_platforms " << to_string(*value); + } + continue; + } if (key == "emojies_animated_zoom") { animated_emoji_zoom = get_json_value_double(std::move(key_value->value_), key); continue; @@ -1851,6 +1871,11 @@ void ConfigManager::process_app_config(tl_object_ptr &c get_content_settings(Auto()); } } + if (restriction_add_platforms.empty()) { + options.set_option_empty("restriction_add_platforms"); + } else { + options.set_option_string("restriction_add_platforms", restriction_add_platforms); + } if (!dice_emojis.empty()) { vector dice_success_values(dice_emojis.size()); diff --git a/td/telegram/RestrictionReason.cpp b/td/telegram/RestrictionReason.cpp index c23d895fb..8b9ef8dd6 100644 --- a/td/telegram/RestrictionReason.cpp +++ b/td/telegram/RestrictionReason.cpp @@ -22,11 +22,8 @@ string get_restriction_reason_description(const vector &restr } auto ignored_restriction_reasons = full_split(G()->get_option_string("ignored_restriction_reasons"), ','); + auto restriction_add_platforms = full_split(G()->get_option_string("restriction_add_platforms"), ','); auto platform = [] { - if (G()->get_option_boolean("ignore_platform_restrictions")) { - return Slice(); - } - #if TD_ANDROID return Slice("android"); #elif TD_WINDOWS @@ -38,7 +35,13 @@ string get_restriction_reason_description(const vector &restr #endif }(); + if (G()->get_option_boolean("ignore_platform_restrictions")) { + platform = Slice(); + restriction_add_platforms.clear(); + } + if (!platform.empty()) { + // first find restriction for the current platform for (auto &restriction_reason : restriction_reasons) { if (restriction_reason.platform_ == platform && !td::contains(ignored_restriction_reasons, restriction_reason.reason_)) { @@ -47,6 +50,17 @@ string get_restriction_reason_description(const vector &restr } } + if (!restriction_add_platforms.empty()) { + // then find restriction for added platforms + for (auto &restriction_reason : restriction_reasons) { + if (td::contains(restriction_add_platforms, restriction_reason.platform_) && + !td::contains(ignored_restriction_reasons, restriction_reason.reason_)) { + return restriction_reason.description_; + } + } + } + + // then find restriction for all platforms for (auto &restriction_reason : restriction_reasons) { if (restriction_reason.platform_ == "all" && !td::contains(ignored_restriction_reasons, restriction_reason.reason_)) {