Remove "archive_and_mute_new_chats_from_unknown_users" option.

This commit is contained in:
levlam 2023-07-14 15:41:38 +03:00
parent d5c8a68876
commit 6685bcfd7a
3 changed files with 3 additions and 120 deletions

View File

@ -1083,45 +1083,6 @@ void ConfigManager::set_content_settings(bool ignore_sensitive_content_restricti
}
}
void ConfigManager::get_global_privacy_settings(Promise<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
auto auth_manager = G()->td().get_actor_unsafe()->auth_manager_.get();
if (auth_manager == nullptr || !auth_manager->is_authorized() || auth_manager->is_bot()) {
return promise.set_value(Unit());
}
get_global_privacy_settings_queries_.push_back(std::move(promise));
if (get_global_privacy_settings_queries_.size() == 1) {
G()->net_query_dispatcher().dispatch_with_callback(
G()->net_query_creator().create(telegram_api::account_getGlobalPrivacySettings()), actor_shared(this, 5));
}
}
void ConfigManager::set_archive_and_mute(bool archive_and_mute, Promise<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
if (archive_and_mute) {
remove_suggested_action(suggested_actions_, SuggestedAction{SuggestedAction::Type::EnableArchiveAndMuteNewChats});
}
last_set_archive_and_mute_ = archive_and_mute;
auto &queries = set_archive_and_mute_queries_[archive_and_mute];
queries.push_back(std::move(promise));
if (!is_set_archive_and_mute_request_sent_) {
is_set_archive_and_mute_request_sent_ = true;
int32 flags = 0;
if (archive_and_mute) {
flags |= telegram_api::globalPrivacySettings::ARCHIVE_AND_MUTE_NEW_NONCONTACT_PEERS_MASK;
}
auto settings = make_tl_object<telegram_api::globalPrivacySettings>(flags, false /*ignored*/, false /*ignored*/,
false /*ignored*/);
G()->net_query_dispatcher().dispatch_with_callback(
G()->net_query_creator().create(telegram_api::account_setGlobalPrivacySettings(std::move(settings))),
actor_shared(this, 6 + static_cast<uint64>(archive_and_mute)));
}
}
void ConfigManager::on_dc_options_update(DcOptions dc_options) {
save_dc_options_update(dc_options);
if (!dc_options.dc_options.empty()) {
@ -1149,13 +1110,6 @@ void ConfigManager::do_set_ignore_sensitive_content_restrictions(bool ignore_sen
}
}
void ConfigManager::do_set_archive_and_mute(bool archive_and_mute) {
if (archive_and_mute) {
remove_suggested_action(suggested_actions_, SuggestedAction{SuggestedAction::Type::EnableArchiveAndMuteNewChats});
}
G()->set_option_boolean("archive_and_mute_new_chats_from_unknown_users", archive_and_mute);
}
void ConfigManager::hide_suggested_action(SuggestedAction suggested_action) {
remove_suggested_action(suggested_actions_, suggested_action);
}
@ -1204,42 +1158,6 @@ void ConfigManager::on_result(NetQueryPtr res) {
set_promises(promises);
return;
}
if (token == 6 || token == 7) {
is_set_archive_and_mute_request_sent_ = false;
bool archive_and_mute = (token == 7);
auto result_ptr = fetch_result<telegram_api::account_setGlobalPrivacySettings>(std::move(res));
if (result_ptr.is_error()) {
fail_promises(set_archive_and_mute_queries_[archive_and_mute], result_ptr.move_as_error());
} else {
if (last_set_archive_and_mute_ == archive_and_mute) {
do_set_archive_and_mute(archive_and_mute);
}
set_promises(set_archive_and_mute_queries_[archive_and_mute]);
}
if (!set_archive_and_mute_queries_[!archive_and_mute].empty()) {
if (archive_and_mute == last_set_archive_and_mute_) {
set_promises(set_archive_and_mute_queries_[!archive_and_mute]);
} else {
set_archive_and_mute(!archive_and_mute, Auto());
}
}
return;
}
if (token == 5) {
auto result_ptr = fetch_result<telegram_api::account_getGlobalPrivacySettings>(std::move(res));
if (result_ptr.is_error()) {
fail_promises(get_global_privacy_settings_queries_, result_ptr.move_as_error());
return;
}
auto result = result_ptr.move_as_ok();
do_set_archive_and_mute(result->archive_and_mute_new_noncontact_peers_);
set_promises(get_global_privacy_settings_queries_);
return;
}
if (token == 3 || token == 4) {
is_set_content_settings_request_sent_ = false;
bool ignore_sensitive_content_restrictions = (token == 4);
@ -1519,9 +1437,6 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
!options.have_option("ignore_sensitive_content_restrictions")) {
get_content_settings(Auto());
}
if (!options.have_option("archive_and_mute_new_chats_from_unknown_users")) {
get_global_privacy_settings(Auto());
}
}
}
@ -1734,17 +1649,13 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
if (key == "pending_suggestions") {
if (value->get_id() == telegram_api::jsonArray::ID) {
auto actions = std::move(static_cast<telegram_api::jsonArray *>(value)->value_);
const bool archive_and_mute = G()->get_option_boolean("archive_and_mute_new_chats_from_unknown_users");
auto otherwise_relogin_days = G()->get_option_integer("otherwise_relogin_days");
for (auto &action : actions) {
auto action_str = get_json_value_string(std::move(action), key);
SuggestedAction suggested_action(action_str);
if (!suggested_action.is_empty()) {
if (archive_and_mute &&
suggested_action == SuggestedAction{SuggestedAction::Type::EnableArchiveAndMuteNewChats}) {
LOG(INFO) << "Skip EnableArchiveAndMuteNewChats suggested action";
} else if (otherwise_relogin_days > 0 &&
suggested_action == SuggestedAction{SuggestedAction::Type::SetPassword}) {
if (otherwise_relogin_days > 0 &&
suggested_action == SuggestedAction{SuggestedAction::Type::SetPassword}) {
LOG(INFO) << "Skip SetPassword suggested action";
} else {
suggested_actions.push_back(suggested_action);

View File

@ -92,10 +92,6 @@ class ConfigManager final : public NetQueryCallback {
void set_content_settings(bool ignore_sensitive_content_restrictions, Promise<Unit> &&promise);
void get_global_privacy_settings(Promise<Unit> &&promise);
void set_archive_and_mute(bool archive_and_mute, Promise<Unit> &&promise);
void hide_suggested_action(SuggestedAction suggested_action);
void dismiss_suggested_action(SuggestedAction suggested_action, Promise<Unit> &&promise);
@ -137,11 +133,6 @@ class ConfigManager final : public NetQueryCallback {
bool is_set_content_settings_request_sent_ = false;
bool last_set_content_settings_ = false;
vector<Promise<Unit>> get_global_privacy_settings_queries_;
vector<Promise<Unit>> set_archive_and_mute_queries_[2];
bool is_set_archive_and_mute_request_sent_ = false;
bool last_set_archive_and_mute_ = false;
AppConfig app_config_;
vector<SuggestedAction> suggested_actions_;
@ -167,8 +158,6 @@ class ConfigManager final : public NetQueryCallback {
void do_set_ignore_sensitive_content_restrictions(bool ignore_sensitive_content_restrictions);
void do_set_archive_and_mute(bool archive_and_mute);
static Timestamp load_config_expire_time();
static void save_config_expire(Timestamp timestamp);
static void save_dc_options_update(const DcOptions &dc_options);

View File

@ -118,6 +118,7 @@ OptionManager::OptionManager(Td *td)
set_option_boolean("archive_all_stories", false);
}
set_option_empty("archive_and_mute_new_chats_from_unknown_users");
set_option_empty("chat_filter_count_max");
set_option_empty("chat_filter_chosen_chat_count_max");
set_option_empty("forum_member_count_min");
@ -482,11 +483,6 @@ void OptionManager::get_option(const string &name, Promise<td_api::object_ptr<td
};
switch (name[0]) {
// all these options should be added to getCurrentState
case 'a':
if (!is_bot && name == "archive_and_mute_new_chats_from_unknown_users") {
return send_closure_later(td_->config_manager_, &ConfigManager::get_global_privacy_settings, wrap_promise());
}
break;
case 'c':
if (!is_bot && name == "can_ignore_sensitive_content_restrictions") {
return send_closure_later(td_->config_manager_, &ConfigManager::get_content_settings, wrap_promise());
@ -634,19 +630,6 @@ void OptionManager::set_option(const string &name, td_api::object_ptr<td_api::Op
set_option_boolean("need_synchronize_archive_all_stories", true);
return;
}
if (!is_bot && name == "archive_and_mute_new_chats_from_unknown_users") {
if (value_constructor_id != td_api::optionValueBoolean::ID &&
value_constructor_id != td_api::optionValueEmpty::ID) {
return promise.set_error(
Status::Error(400, "Option \"archive_and_mute_new_chats_from_unknown_users\" must have boolean value"));
}
auto archive_and_mute = value_constructor_id == td_api::optionValueBoolean::ID &&
static_cast<td_api::optionValueBoolean *>(value.get())->value_;
send_closure_later(td_->config_manager_, &ConfigManager::set_archive_and_mute, archive_and_mute,
std::move(promise));
return;
}
break;
case 'c':
if (!is_bot && set_string_option("connection_parameters", [](Slice value) {