diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 4e90f99d5..5a5850e67 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -5200,6 +5200,9 @@ void Td::on_request(uint64 id, td_api::optimizeStorage &request) { void Td::on_request(uint64 id, td_api::getNetworkStatistics &request) { CREATE_REQUEST_PROMISE(); + if (!request.only_current_ && G()->shared_config().get_option_boolean("disable_persistent_network_statistics")) { + return send_error_raw(id, 400, "Persistent network statistics is disabled"); + } auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result result) mutable { if (result.is_error()) { promise.set_error(result.move_as_error()); @@ -7001,6 +7004,9 @@ void Td::on_request(uint64 id, td_api::setOption &request) { if (!is_bot && set_boolean_option("disable_top_chats")) { return; } + if (set_boolean_option("disable_persistent_network_statistics")) { + return; + } if (request.name_ == "drop_notification_ids") { G()->td_db()->get_binlog_pmc()->erase("notification_id_current"); G()->td_db()->get_binlog_pmc()->erase("notification_group_id_current"); diff --git a/td/telegram/net/NetStatsManager.cpp b/td/telegram/net/NetStatsManager.cpp index 2c4dadff3..931e1c5f1 100644 --- a/td/telegram/net/NetStatsManager.cpp +++ b/td/telegram/net/NetStatsManager.cpp @@ -291,6 +291,10 @@ void NetStatsManager::update(NetStatsInfo &info, bool force_save) { } void NetStatsManager::save_stats(NetStatsInfo &info, NetType net_type) { + if (G()->shared_config().get_option_boolean("disable_persistent_network_statistics")) { + return; + } + auto net_type_i = static_cast(net_type); auto &type_stats = info.stats_by_type[net_type_i];