From 45dfb58cc5f42faf0c631e8a44ae1bcae3cd872d Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 5 Feb 2021 01:40:53 +0300 Subject: [PATCH] Save autologin domains between restarts. --- td/telegram/ConfigManager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index d392ffe35..7a1cc62b3 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -891,6 +891,7 @@ void ConfigManager::start_up() { } autologin_update_time_ = Time::now() - 365 * 86400; + autologin_domains_ = full_split(G()->td_db()->get_binlog_pmc()->get("autologin_domains"), '\xFF'); } ActorShared<> ConfigManager::create_reference() { @@ -1532,6 +1533,7 @@ void ConfigManager::process_app_config(tl_object_ptr &c G()->shared_config().get_option_boolean("archive_and_mute_new_chats_from_unknown_users"); autologin_token_.clear(); + auto old_autologin_domains = std::move(autologin_domains_); autologin_domains_.clear(); autologin_update_time_ = Time::now(); @@ -1732,6 +1734,10 @@ void ConfigManager::process_app_config(tl_object_ptr &c } config = make_tl_object(std::move(new_values)); + if (autologin_domains_ != old_autologin_domains) { + G()->td_db()->get_binlog_pmc()->set("autologin_domains", implode(autologin_domains_, '\xFF')); + } + ConfigShared &shared_config = G()->shared_config(); if (ignored_restriction_reasons.empty()) {