From 2743e006decf7c55ee0df0c96b28125f72dad812 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 15 Aug 2024 19:23:45 +0300 Subject: [PATCH] Use get_current_country_code() to test network. --- td/telegram/Requests.cpp | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/td/telegram/Requests.cpp b/td/telegram/Requests.cpp index 658118153..4c19b64d5 100644 --- a/td/telegram/Requests.cpp +++ b/td/telegram/Requests.cpp @@ -276,33 +276,6 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler { } }; -class TestNetworkQuery final : public Td::ResultHandler { - Promise promise_; - - public: - explicit TestNetworkQuery(Promise &&promise) : promise_(std::move(promise)) { - } - - void send() { - send_query(G()->net_query_creator().create_unauth(telegram_api::help_getConfig())); - } - - void on_result(BufferSlice packet) final { - auto result_ptr = fetch_result(packet); - if (result_ptr.is_error()) { - return on_error(Status::Error(500, "Fetch failed")); - } - - LOG(DEBUG) << "TestNetwork OK: " << to_string(result_ptr.ok()); - promise_.set_value(Unit()); - } - - void on_error(Status status) final { - LOG(ERROR) << "Test query failed: " << status; - promise_.set_error(std::move(status)); - } -}; - class GetMeRequest final : public RequestActor<> { UserId user_id_; @@ -8048,7 +8021,14 @@ void Requests::on_request(uint64 id, const td_api::addLogMessage &request) { // test void Requests::on_request(uint64 id, const td_api::testNetwork &request) { CREATE_OK_REQUEST_PROMISE(); - td_->create_handler(std::move(promise))->send(); + auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result result) mutable { + if (result.is_error()) { + promise.set_error(result.move_as_error()); + } else { + promise.set_value(Unit()); + } + }); + td_->country_info_manager_->get_current_country_code(std::move(query_promise)); } void Requests::on_request(uint64 id, td_api::testProxy &request) {