Skip to content

Commit ad431a6

Browse files
committed
tg_cli: maintain authorization state.
1 parent 14637ca commit ad431a6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

td/telegram/cli.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,9 @@ class CliClient final : public Actor {
389389
}
390390
}
391391

392-
void on_update_autorization_state(const td_api::AuthorizationState &state) {
393-
switch (state.get_id()) {
392+
void on_update_autorization_state(td_api::object_ptr<td_api::AuthorizationState> &&state) {
393+
authorization_state_ = std::move(state);
394+
switch (authorization_state_->get_id()) {
394395
case td_api::authorizationStateWaitTdlibParameters::ID: {
395396
auto parameters = td_api::make_object<td_api::tdlibParameters>();
396397
parameters->use_test_dc_ = use_test_dc_;
@@ -854,7 +855,7 @@ class CliClient final : public Actor {
854855
break;
855856
case td_api::updateAuthorizationState::ID:
856857
on_update_autorization_state(
857-
*(static_cast<const td_api::updateAuthorizationState *>(result.get())->authorization_state_));
858+
std::move(static_cast<td_api::updateAuthorizationState *>(result.get())->authorization_state_));
858859
break;
859860
case td_api::updateChatLastMessage::ID: {
860861
auto message = static_cast<const td_api::updateChatLastMessage *>(result.get())->last_message_.get();
@@ -1681,7 +1682,7 @@ class CliClient final : public Actor {
16811682
int32 op_not_found_count = 0;
16821683

16831684
if (op == "gas") {
1684-
send_request(td_api::make_object<td_api::getAuthorizationState>());
1685+
LOG(ERROR) << to_string(authorization_state_);
16851686
} else if (op == "sap" || op == "sapn") {
16861687
send_request(
16871688
td_api::make_object<td_api::setAuthenticationPhoneNumber>(args, get_phone_number_authentication_settings()));
@@ -4670,6 +4671,7 @@ class CliClient final : public Actor {
46704671
std::unordered_map<int32, double> being_downloaded_files_;
46714672

46724673
int64 my_id_ = 0;
4674+
td_api::object_ptr<td_api::AuthorizationState> authorization_state_;
46734675
string schedule_date_;
46744676
string message_thread_id_;
46754677
int64 opened_chat_id_ = 0;

0 commit comments

Comments
 (0)