From 75bdc6292b488c195645a01b9242c7dab9d01fd1 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 12 Jan 2023 22:25:47 +0300 Subject: [PATCH] Remove some getAuthorizationState usages. --- example/python/tdjson_example.py | 4 ++-- example/uwp/app/MainPage.xaml.cs | 5 ----- td/generate/DoxygenTlDocumentationGenerator.php | 2 +- td/tl/TlObject.h | 2 +- test/online.cpp | 9 ++------- test/tdclient.cpp | 9 ++------- 6 files changed, 8 insertions(+), 23 deletions(-) diff --git a/example/python/tdjson_example.py b/example/python/tdjson_example.py index 4ee23f2c3..ce8d9f9ba 100644 --- a/example/python/tdjson_example.py +++ b/example/python/tdjson_example.py @@ -75,8 +75,8 @@ def td_receive(): # another test for TDLib execute method print(str(td_execute({'@type': 'getTextEntities', 'text': '@telegram /test_command https://telegram.org telegram.me', '@extra': ['5', 7.0, 'a']})).encode('utf-8')) -# start the client by sending request to it -td_send({'@type': 'getAuthorizationState', '@extra': 1.01234}) +# start the client by sending a request to it +td_send({'@type': 'getOption', 'name': 'version', '@extra': 1.01234}) # main events cycle while True: diff --git a/example/uwp/app/MainPage.xaml.cs b/example/uwp/app/MainPage.xaml.cs index 82c7fdd0d..e4218386e 100644 --- a/example/uwp/app/MainPage.xaml.cs +++ b/example/uwp/app/MainPage.xaml.cs @@ -85,11 +85,6 @@ namespace TdApp AcceptCommand("LogOut"); _client.Send(new TdApi.LogOut(), _handler); } - else if (command.StartsWith("gas")) - { - AcceptCommand(command); - _client.Send(new TdApi.GetAuthorizationState(), _handler); - } else if (command.StartsWith("sap")) { var args = command.Split(" ".ToCharArray(), 2); diff --git a/td/generate/DoxygenTlDocumentationGenerator.php b/td/generate/DoxygenTlDocumentationGenerator.php index dc89536b2..2d5a37b2c 100644 --- a/td/generate/DoxygenTlDocumentationGenerator.php +++ b/td/generate/DoxygenTlDocumentationGenerator.php @@ -231,7 +231,7 @@ EOT * A function to create a dynamically allocated TDLib API object. Can be treated as an analogue of std::make_unique. * Usage example: * \\code - * auto get_authorization_state_request = td::td_api::make_object(); + * auto get_me_request = td::td_api::make_object(); * auto message_text = td::td_api::make_object("Hello, world!!!", * td::td_api::array>()); * auto send_message_request = td::td_api::make_object(chat_id, 0, 0, nullptr, nullptr, diff --git a/td/tl/TlObject.h b/td/tl/TlObject.h index 399637d09..5c5e76d2c 100644 --- a/td/tl/TlObject.h +++ b/td/tl/TlObject.h @@ -187,7 +187,7 @@ using tl_object_ptr = tl::unique_ptr; * A function to create a dynamically allocated TL-object. Can be treated as an analogue of std::make_unique. * Usage example: * \code - * auto get_authorization_state_request = td::make_tl_object(); + * auto get_me_request = td::make_tl_object(); * auto message_text = td::make_tl_object("Hello, world!!!", * td::td_api::array>()); * auto send_message_request = td::make_tl_object(chat_id, 0, 0, nullptr, nullptr, diff --git a/test/online.cpp b/test/online.cpp index 1ffc5523f..fd758129d 100644 --- a/test/online.cpp +++ b/test/online.cpp @@ -221,14 +221,12 @@ class InitTask : public Task { private: Options options_; td::Promise<> promise_; - bool start_flag_{false}; void start_up() override { - send_query(td::make_tl_object(), - [this](auto res) { this->process_authorization_state(res.move_as_ok()); }); + send_query(td::make_tl_object("version"), + [](auto res) { LOG(INFO) << td::td_api::to_string(res.ok()); }); } void process_authorization_state(td::tl_object_ptr authorization_state) { - start_flag_ = true; td::tl_object_ptr function; switch (authorization_state->get_id()) { case td::td_api::authorizationStateReady::ID: @@ -267,9 +265,6 @@ class InitTask : public Task { }); } void process_update(std::shared_ptr update) override { - if (!start_flag_) { - return; - } if (!update->object) { return; } diff --git a/test/tdclient.cpp b/test/tdclient.cpp index 6d8dd383c..3514089b7 100644 --- a/test/tdclient.cpp +++ b/test/tdclient.cpp @@ -204,11 +204,10 @@ class DoAuthentication final : public TestClinetTask { : name_(std::move(name)), phone_(std::move(phone)), code_(std::move(code)), promise_(std::move(promise)) { } void start_up() final { - send_query(td::make_tl_object(), - [this](auto res) { this->process_authorization_state(std::move(res)); }); + send_query(td::make_tl_object("version"), + [](auto res) { LOG(INFO) << td::td_api::to_string(res); }); } void process_authorization_state(td::tl_object_ptr authorization_state) { - start_flag_ = true; td::tl_object_ptr function; switch (authorization_state->get_id()) { case td::td_api::authorizationStateWaitPhoneNumber::ID: @@ -261,12 +260,8 @@ class DoAuthentication final : public TestClinetTask { td::string phone_; td::string code_; td::Promise<> promise_; - bool start_flag_{false}; void process_update(std::shared_ptr update) final { - if (!start_flag_) { - return; - } if (!update->object) { return; }