Support "restriction_add_platforms" app config parameter.
This commit is contained in:
parent
d1afd1c3b7
commit
c6d1940537
@ -1471,6 +1471,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
|||||||
|
|
||||||
vector<tl_object_ptr<telegram_api::jsonObjectValue>> new_values;
|
vector<tl_object_ptr<telegram_api::jsonObjectValue>> new_values;
|
||||||
string ignored_restriction_reasons;
|
string ignored_restriction_reasons;
|
||||||
|
string restriction_add_platforms;
|
||||||
vector<string> dice_emojis;
|
vector<string> dice_emojis;
|
||||||
FlatHashMap<string, size_t> dice_emoji_index;
|
FlatHashMap<string, size_t> dice_emoji_index;
|
||||||
FlatHashMap<string, string> dice_emoji_success_value;
|
FlatHashMap<string, string> dice_emoji_success_value;
|
||||||
@ -1519,6 +1520,25 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (key == "restriction_add_platforms") {
|
||||||
|
if (value->get_id() == telegram_api::jsonArray::ID) {
|
||||||
|
auto platforms = std::move(static_cast<telegram_api::jsonArray *>(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") {
|
if (key == "emojies_animated_zoom") {
|
||||||
animated_emoji_zoom = get_json_value_double(std::move(key_value->value_), key);
|
animated_emoji_zoom = get_json_value_double(std::move(key_value->value_), key);
|
||||||
continue;
|
continue;
|
||||||
@ -1851,6 +1871,11 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
|||||||
get_content_settings(Auto());
|
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()) {
|
if (!dice_emojis.empty()) {
|
||||||
vector<string> dice_success_values(dice_emojis.size());
|
vector<string> dice_success_values(dice_emojis.size());
|
||||||
|
@ -22,11 +22,8 @@ string get_restriction_reason_description(const vector<RestrictionReason> &restr
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto ignored_restriction_reasons = full_split(G()->get_option_string("ignored_restriction_reasons"), ',');
|
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 = [] {
|
auto platform = [] {
|
||||||
if (G()->get_option_boolean("ignore_platform_restrictions")) {
|
|
||||||
return Slice();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if TD_ANDROID
|
#if TD_ANDROID
|
||||||
return Slice("android");
|
return Slice("android");
|
||||||
#elif TD_WINDOWS
|
#elif TD_WINDOWS
|
||||||
@ -38,7 +35,13 @@ string get_restriction_reason_description(const vector<RestrictionReason> &restr
|
|||||||
#endif
|
#endif
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
if (G()->get_option_boolean("ignore_platform_restrictions")) {
|
||||||
|
platform = Slice();
|
||||||
|
restriction_add_platforms.clear();
|
||||||
|
}
|
||||||
|
|
||||||
if (!platform.empty()) {
|
if (!platform.empty()) {
|
||||||
|
// first find restriction for the current platform
|
||||||
for (auto &restriction_reason : restriction_reasons) {
|
for (auto &restriction_reason : restriction_reasons) {
|
||||||
if (restriction_reason.platform_ == platform &&
|
if (restriction_reason.platform_ == platform &&
|
||||||
!td::contains(ignored_restriction_reasons, restriction_reason.reason_)) {
|
!td::contains(ignored_restriction_reasons, restriction_reason.reason_)) {
|
||||||
@ -47,6 +50,17 @@ string get_restriction_reason_description(const vector<RestrictionReason> &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) {
|
for (auto &restriction_reason : restriction_reasons) {
|
||||||
if (restriction_reason.platform_ == "all" &&
|
if (restriction_reason.platform_ == "all" &&
|
||||||
!td::contains(ignored_restriction_reasons, restriction_reason.reason_)) {
|
!td::contains(ignored_restriction_reasons, restriction_reason.reason_)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user