From 4ce946a310a2fec3ac07fe8760b133d071991081 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 20 Dec 2019 04:19:40 +0300 Subject: [PATCH] Reload app config after ignore_sensitive_content_restrictions is changed. GitOrigin-RevId: fa7438017444e41a9b067d52c681e101579cc978 --- td/telegram/ConfigManager.cpp | 19 ++++++++++++------- td/telegram/ConfigManager.h | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index 9bd9d840..b3ddbdcc 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -991,6 +991,14 @@ void ConfigManager::request_config_from_dc_impl(DcId dc_id) { actor_shared(this, 0)); } +void ConfigManager::set_ignore_sensitive_content_restrictions(bool ignore_sensitive_content_restrictions) { + G()->shared_config().set_option_boolean("ignore_sensitive_content_restrictions", ignore_sensitive_content_restrictions); + bool have_ignored_restriction_reasons = G()->shared_config().have_option("ignored_restriction_reasons"); + if (have_ignored_restriction_reasons != ignore_sensitive_content_restrictions) { + get_app_config(Auto()); + } +} + void ConfigManager::on_result(NetQueryPtr res) { auto token = get_link_token(); if (token == 3 || token == 4) { @@ -1005,11 +1013,9 @@ void ConfigManager::on_result(NetQueryPtr res) { promise.set_error(result_ptr.error().clone()); } } else { - ConfigShared &shared_config = G()->shared_config(); - if (shared_config.get_option_boolean("can_ignore_sensitive_content_restrictions") && + if (G()->shared_config().get_option_boolean("can_ignore_sensitive_content_restrictions") && last_set_content_settings_ == ignore_sensitive_content_restrictions) { - shared_config.set_option_boolean("ignore_sensitive_content_restrictions", - ignore_sensitive_content_restrictions); + set_ignore_sensitive_content_restrictions(ignore_sensitive_content_restrictions); } for (auto &promise : promises) { @@ -1043,9 +1049,8 @@ void ConfigManager::on_result(NetQueryPtr res) { } auto result = result_ptr.move_as_ok(); - ConfigShared &shared_config = G()->shared_config(); - shared_config.set_option_boolean("ignore_sensitive_content_restrictions", result->sensitive_enabled_); - shared_config.set_option_boolean("can_ignore_sensitive_content_restrictions", result->sensitive_can_change_); + set_ignore_sensitive_content_restrictions(result->sensitive_enabled_); + G()->shared_config().set_option_boolean("can_ignore_sensitive_content_restrictions", result->sensitive_can_change_); for (auto &promise : promises) { promise.set_value(Unit()); diff --git a/td/telegram/ConfigManager.h b/td/telegram/ConfigManager.h index f0ad4b8e..d2b7b79b 100644 --- a/td/telegram/ConfigManager.h +++ b/td/telegram/ConfigManager.h @@ -115,6 +115,7 @@ class ConfigManager : public NetQueryCallback { void request_config_from_dc_impl(DcId dc_id); void process_config(tl_object_ptr config); void process_app_config(tl_object_ptr &config); + void set_ignore_sensitive_content_restrictions(bool ignore_sensitive_content_restrictions); Timestamp load_config_expire_time(); void save_config_expire(Timestamp timestamp);