Improve NetQueryPtr variable names.
This commit is contained in:
parent
1f38e4d49f
commit
ce2e7192d7
@ -876,16 +876,16 @@ void AuthManager::on_sent_code(telegram_api::object_ptr<telegram_api::auth_SentC
|
||||
on_query_ok();
|
||||
}
|
||||
|
||||
void AuthManager::on_send_code_result(NetQueryPtr &result) {
|
||||
auto r_sent_code = fetch_result<telegram_api::auth_sendCode>(std::move(result));
|
||||
void AuthManager::on_send_code_result(NetQueryPtr &&net_query) {
|
||||
auto r_sent_code = fetch_result<telegram_api::auth_sendCode>(std::move(net_query));
|
||||
if (r_sent_code.is_error()) {
|
||||
return on_current_query_error(r_sent_code.move_as_error());
|
||||
}
|
||||
on_sent_code(r_sent_code.move_as_ok());
|
||||
}
|
||||
|
||||
void AuthManager::on_send_email_code_result(NetQueryPtr &result) {
|
||||
auto r_sent_code = fetch_result<telegram_api::account_sendVerifyEmailCode>(std::move(result));
|
||||
void AuthManager::on_send_email_code_result(NetQueryPtr &&net_query) {
|
||||
auto r_sent_code = fetch_result<telegram_api::account_sendVerifyEmailCode>(std::move(net_query));
|
||||
if (r_sent_code.is_error()) {
|
||||
return on_current_query_error(r_sent_code.move_as_error());
|
||||
}
|
||||
@ -902,8 +902,8 @@ void AuthManager::on_send_email_code_result(NetQueryPtr &result) {
|
||||
on_query_ok();
|
||||
}
|
||||
|
||||
void AuthManager::on_verify_email_address_result(NetQueryPtr &result) {
|
||||
auto r_email_verified = fetch_result<telegram_api::account_verifyEmail>(std::move(result));
|
||||
void AuthManager::on_verify_email_address_result(NetQueryPtr &&net_query) {
|
||||
auto r_email_verified = fetch_result<telegram_api::account_verifyEmail>(std::move(net_query));
|
||||
if (r_email_verified.is_error()) {
|
||||
return on_current_query_error(r_email_verified.move_as_error());
|
||||
}
|
||||
@ -920,8 +920,8 @@ void AuthManager::on_verify_email_address_result(NetQueryPtr &result) {
|
||||
on_sent_code(std::move(verified_login->sent_code_));
|
||||
}
|
||||
|
||||
void AuthManager::on_reset_email_address_result(NetQueryPtr &result) {
|
||||
auto r_sent_code = fetch_result<telegram_api::auth_resetLoginEmail>(std::move(result));
|
||||
void AuthManager::on_reset_email_address_result(NetQueryPtr &&net_query) {
|
||||
auto r_sent_code = fetch_result<telegram_api::auth_resetLoginEmail>(std::move(net_query));
|
||||
if (r_sent_code.is_error()) {
|
||||
if (reset_available_period_ > 0 && reset_pending_date_ == -1 &&
|
||||
r_sent_code.error().message() == "TASK_ALREADY_EXISTS") {
|
||||
@ -934,8 +934,8 @@ void AuthManager::on_reset_email_address_result(NetQueryPtr &result) {
|
||||
on_sent_code(r_sent_code.move_as_ok());
|
||||
}
|
||||
|
||||
void AuthManager::on_request_qr_code_result(NetQueryPtr &result, bool is_import) {
|
||||
auto r_login_token = fetch_result<telegram_api::auth_exportLoginToken>(std::move(result));
|
||||
void AuthManager::on_request_qr_code_result(NetQueryPtr &&net_query, bool is_import) {
|
||||
auto r_login_token = fetch_result<telegram_api::auth_exportLoginToken>(std::move(net_query));
|
||||
if (r_login_token.is_ok()) {
|
||||
auto login_token = r_login_token.move_as_ok();
|
||||
|
||||
@ -1005,8 +1005,8 @@ void AuthManager::on_get_login_token(tl_object_ptr<telegram_api::auth_LoginToken
|
||||
}
|
||||
}
|
||||
|
||||
void AuthManager::on_get_password_result(NetQueryPtr &result) {
|
||||
auto r_password = fetch_result<telegram_api::account_getPassword>(std::move(result));
|
||||
void AuthManager::on_get_password_result(NetQueryPtr &&net_query) {
|
||||
auto r_password = fetch_result<telegram_api::account_getPassword>(std::move(net_query));
|
||||
if (r_password.is_error() && query_id_ != 0) {
|
||||
return on_current_query_error(r_password.move_as_error());
|
||||
}
|
||||
@ -1088,8 +1088,8 @@ void AuthManager::on_get_password_result(NetQueryPtr &result) {
|
||||
}
|
||||
}
|
||||
|
||||
void AuthManager::on_request_password_recovery_result(NetQueryPtr &result) {
|
||||
auto r_email_address_pattern = fetch_result<telegram_api::auth_requestPasswordRecovery>(std::move(result));
|
||||
void AuthManager::on_request_password_recovery_result(NetQueryPtr &&net_query) {
|
||||
auto r_email_address_pattern = fetch_result<telegram_api::auth_requestPasswordRecovery>(std::move(net_query));
|
||||
if (r_email_address_pattern.is_error()) {
|
||||
return on_current_query_error(r_email_address_pattern.move_as_error());
|
||||
}
|
||||
@ -1100,8 +1100,8 @@ void AuthManager::on_request_password_recovery_result(NetQueryPtr &result) {
|
||||
on_query_ok();
|
||||
}
|
||||
|
||||
void AuthManager::on_check_password_recovery_code_result(NetQueryPtr &result) {
|
||||
auto r_success = fetch_result<telegram_api::auth_checkRecoveryPassword>(std::move(result));
|
||||
void AuthManager::on_check_password_recovery_code_result(NetQueryPtr &&net_query) {
|
||||
auto r_success = fetch_result<telegram_api::auth_checkRecoveryPassword>(std::move(net_query));
|
||||
if (r_success.is_error()) {
|
||||
return on_current_query_error(r_success.move_as_error());
|
||||
}
|
||||
@ -1111,16 +1111,16 @@ void AuthManager::on_check_password_recovery_code_result(NetQueryPtr &result) {
|
||||
on_query_ok();
|
||||
}
|
||||
|
||||
void AuthManager::on_request_firebase_sms_result(NetQueryPtr &result) {
|
||||
auto r_bool = fetch_result<telegram_api::auth_requestFirebaseSms>(std::move(result));
|
||||
void AuthManager::on_request_firebase_sms_result(NetQueryPtr &&net_query) {
|
||||
auto r_bool = fetch_result<telegram_api::auth_requestFirebaseSms>(std::move(net_query));
|
||||
if (r_bool.is_error()) {
|
||||
return on_current_query_error(r_bool.move_as_error());
|
||||
}
|
||||
on_query_ok();
|
||||
}
|
||||
|
||||
void AuthManager::on_authentication_result(NetQueryPtr &result, bool is_from_current_query) {
|
||||
auto r_sign_in = fetch_result<telegram_api::auth_signIn>(std::move(result));
|
||||
void AuthManager::on_authentication_result(NetQueryPtr &&net_query, bool is_from_current_query) {
|
||||
auto r_sign_in = fetch_result<telegram_api::auth_signIn>(std::move(net_query));
|
||||
if (r_sign_in.is_error()) {
|
||||
if (is_from_current_query) {
|
||||
return on_current_query_error(r_sign_in.move_as_error());
|
||||
@ -1130,8 +1130,8 @@ void AuthManager::on_authentication_result(NetQueryPtr &result, bool is_from_cur
|
||||
on_get_authorization(r_sign_in.move_as_ok());
|
||||
}
|
||||
|
||||
void AuthManager::on_log_out_result(NetQueryPtr &result) {
|
||||
auto r_log_out = fetch_result<telegram_api::auth_logOut>(std::move(result));
|
||||
void AuthManager::on_log_out_result(NetQueryPtr &&net_query) {
|
||||
auto r_log_out = fetch_result<telegram_api::auth_logOut>(std::move(net_query));
|
||||
if (r_log_out.is_ok()) {
|
||||
auto logged_out = r_log_out.move_as_ok();
|
||||
if (!logged_out->future_auth_token_.empty()) {
|
||||
@ -1178,8 +1178,8 @@ void AuthManager::destroy_auth_keys() {
|
||||
G()->td_db()->get_binlog_pmc()->force_sync(std::move(promise));
|
||||
}
|
||||
|
||||
void AuthManager::on_delete_account_result(NetQueryPtr &result) {
|
||||
auto r_delete_account = fetch_result<telegram_api::account_deleteAccount>(std::move(result));
|
||||
void AuthManager::on_delete_account_result(NetQueryPtr &&net_query) {
|
||||
auto r_delete_account = fetch_result<telegram_api::account_deleteAccount>(std::move(net_query));
|
||||
if (r_delete_account.is_ok()) {
|
||||
if (!r_delete_account.ok()) {
|
||||
// status = Status::Error(500, "Receive false as result of the request");
|
||||
@ -1282,29 +1282,30 @@ void AuthManager::on_get_authorization(tl_object_ptr<telegram_api::auth_Authoriz
|
||||
}
|
||||
}
|
||||
|
||||
void AuthManager::on_result(NetQueryPtr result) {
|
||||
void AuthManager::on_result(NetQueryPtr net_query) {
|
||||
NetQueryType type = NetQueryType::None;
|
||||
LOG(INFO) << "Receive result of query " << result->id() << ", expecting " << net_query_id_ << " with type "
|
||||
LOG(INFO) << "Receive result of query " << net_query->id() << ", expecting " << net_query_id_ << " with type "
|
||||
<< static_cast<int32>(net_query_type_);
|
||||
if (result->id() == net_query_id_) {
|
||||
if (net_query->id() == net_query_id_) {
|
||||
net_query_id_ = 0;
|
||||
type = net_query_type_;
|
||||
net_query_type_ = NetQueryType::None;
|
||||
if (result->is_error()) {
|
||||
if (net_query->is_error()) {
|
||||
if ((type == NetQueryType::SendCode || type == NetQueryType::SendEmailCode ||
|
||||
type == NetQueryType::VerifyEmailAddress || type == NetQueryType::SignIn ||
|
||||
type == NetQueryType::RequestQrCode || type == NetQueryType::ImportQrCode) &&
|
||||
result->error().code() == 401 && result->error().message() == CSlice("SESSION_PASSWORD_NEEDED")) {
|
||||
net_query->error().code() == 401 && net_query->error().message() == CSlice("SESSION_PASSWORD_NEEDED")) {
|
||||
auto dc_id = DcId::main();
|
||||
if (type == NetQueryType::ImportQrCode) {
|
||||
CHECK(DcId::is_valid(imported_dc_id_));
|
||||
dc_id = DcId::internal(imported_dc_id_);
|
||||
}
|
||||
net_query->clear();
|
||||
start_net_query(NetQueryType::GetPassword,
|
||||
G()->net_query_creator().create_unauth(telegram_api::account_getPassword(), dc_id));
|
||||
return;
|
||||
}
|
||||
if (result->error().message() == CSlice("PHONE_NUMBER_BANNED")) {
|
||||
if (net_query->error().message() == CSlice("PHONE_NUMBER_BANNED")) {
|
||||
LOG(ERROR) << "Your phone number was banned for suspicious activity. If you think that this is a mistake, "
|
||||
"please try to log in from an official mobile app and send a email to recover the account by "
|
||||
"following instructions provided by the app.";
|
||||
@ -1318,68 +1319,68 @@ void AuthManager::on_result(NetQueryPtr result) {
|
||||
was_qr_code_request_ = false;
|
||||
was_check_bot_token_ = false;
|
||||
}
|
||||
on_current_query_error(result->move_as_error());
|
||||
on_current_query_error(net_query->move_as_error());
|
||||
return;
|
||||
}
|
||||
if (type != NetQueryType::RequestQrCode && type != NetQueryType::ImportQrCode &&
|
||||
type != NetQueryType::GetPassword) {
|
||||
LOG(INFO) << "Ignore error for net query of type " << static_cast<int32>(type);
|
||||
return;
|
||||
type = NetQueryType::None;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (result->is_ok() && result->ok_tl_constructor() == telegram_api::auth_authorization::ID) {
|
||||
} else if (net_query->is_ok() && net_query->ok_tl_constructor() == telegram_api::auth_authorization::ID) {
|
||||
type = NetQueryType::Authentication;
|
||||
}
|
||||
switch (type) {
|
||||
case NetQueryType::None:
|
||||
result->clear();
|
||||
net_query->clear();
|
||||
break;
|
||||
case NetQueryType::SignIn:
|
||||
case NetQueryType::SignUp:
|
||||
case NetQueryType::BotAuthentication:
|
||||
case NetQueryType::CheckPassword:
|
||||
case NetQueryType::RecoverPassword:
|
||||
on_authentication_result(result, true);
|
||||
on_authentication_result(std::move(net_query), true);
|
||||
break;
|
||||
case NetQueryType::Authentication:
|
||||
on_authentication_result(result, false);
|
||||
on_authentication_result(std::move(net_query), false);
|
||||
break;
|
||||
case NetQueryType::SendCode:
|
||||
on_send_code_result(result);
|
||||
on_send_code_result(std::move(net_query));
|
||||
break;
|
||||
case NetQueryType::SendEmailCode:
|
||||
on_send_email_code_result(result);
|
||||
on_send_email_code_result(std::move(net_query));
|
||||
break;
|
||||
case NetQueryType::VerifyEmailAddress:
|
||||
on_verify_email_address_result(result);
|
||||
on_verify_email_address_result(std::move(net_query));
|
||||
break;
|
||||
case NetQueryType::ResetEmailAddress:
|
||||
on_reset_email_address_result(result);
|
||||
on_reset_email_address_result(std::move(net_query));
|
||||
break;
|
||||
case NetQueryType::RequestQrCode:
|
||||
on_request_qr_code_result(result, false);
|
||||
on_request_qr_code_result(std::move(net_query), false);
|
||||
break;
|
||||
case NetQueryType::ImportQrCode:
|
||||
on_request_qr_code_result(result, true);
|
||||
on_request_qr_code_result(std::move(net_query), true);
|
||||
break;
|
||||
case NetQueryType::GetPassword:
|
||||
on_get_password_result(result);
|
||||
on_get_password_result(std::move(net_query));
|
||||
break;
|
||||
case NetQueryType::RequestPasswordRecovery:
|
||||
on_request_password_recovery_result(result);
|
||||
on_request_password_recovery_result(std::move(net_query));
|
||||
break;
|
||||
case NetQueryType::CheckPasswordRecoveryCode:
|
||||
on_check_password_recovery_code_result(result);
|
||||
on_check_password_recovery_code_result(std::move(net_query));
|
||||
break;
|
||||
case NetQueryType::RequestFirebaseSms:
|
||||
on_request_firebase_sms_result(result);
|
||||
on_request_firebase_sms_result(std::move(net_query));
|
||||
break;
|
||||
case NetQueryType::LogOut:
|
||||
on_log_out_result(result);
|
||||
on_log_out_result(std::move(net_query));
|
||||
break;
|
||||
case NetQueryType::DeleteAccount:
|
||||
on_delete_account_result(result);
|
||||
on_delete_account_result(std::move(net_query));
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -198,22 +198,22 @@ class AuthManager final : public NetActor {
|
||||
|
||||
void on_sent_code(telegram_api::object_ptr<telegram_api::auth_SentCode> &&sent_code_ptr);
|
||||
|
||||
void on_send_code_result(NetQueryPtr &result);
|
||||
void on_send_email_code_result(NetQueryPtr &result);
|
||||
void on_verify_email_address_result(NetQueryPtr &result);
|
||||
void on_reset_email_address_result(NetQueryPtr &result);
|
||||
void on_request_qr_code_result(NetQueryPtr &result, bool is_import);
|
||||
void on_get_password_result(NetQueryPtr &result);
|
||||
void on_request_password_recovery_result(NetQueryPtr &result);
|
||||
void on_check_password_recovery_code_result(NetQueryPtr &result);
|
||||
void on_request_firebase_sms_result(NetQueryPtr &result);
|
||||
void on_authentication_result(NetQueryPtr &result, bool is_from_current_query);
|
||||
void on_log_out_result(NetQueryPtr &result);
|
||||
void on_delete_account_result(NetQueryPtr &result);
|
||||
void on_send_code_result(NetQueryPtr &&net_query);
|
||||
void on_send_email_code_result(NetQueryPtr &&net_query);
|
||||
void on_verify_email_address_result(NetQueryPtr &&net_query);
|
||||
void on_reset_email_address_result(NetQueryPtr &&net_query);
|
||||
void on_request_qr_code_result(NetQueryPtr &&net_query, bool is_import);
|
||||
void on_get_password_result(NetQueryPtr &&net_query);
|
||||
void on_request_password_recovery_result(NetQueryPtr &&net_query);
|
||||
void on_check_password_recovery_code_result(NetQueryPtr &&net_query);
|
||||
void on_request_firebase_sms_result(NetQueryPtr &&net_query);
|
||||
void on_authentication_result(NetQueryPtr &&net_query, bool is_from_current_query);
|
||||
void on_log_out_result(NetQueryPtr &&net_query);
|
||||
void on_delete_account_result(NetQueryPtr &&net_query);
|
||||
void on_get_login_token(tl_object_ptr<telegram_api::auth_LoginToken> login_token);
|
||||
void on_get_authorization(tl_object_ptr<telegram_api::auth_Authorization> auth_ptr);
|
||||
|
||||
void on_result(NetQueryPtr result) final;
|
||||
void on_result(NetQueryPtr net_query) final;
|
||||
|
||||
void update_state(State new_state, bool force = false, bool should_save_state = true);
|
||||
tl_object_ptr<td_api::AuthorizationState> get_authorization_state_object(State authorization_state) const;
|
||||
|
@ -1138,7 +1138,7 @@ void ConfigManager::dismiss_suggested_action(SuggestedAction suggested_action, P
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigManager::on_result(NetQueryPtr res) {
|
||||
void ConfigManager::on_result(NetQueryPtr net_query) {
|
||||
auto token = get_link_token();
|
||||
if (token >= 100 && token <= 200) {
|
||||
auto type = static_cast<int32>(token - 100);
|
||||
@ -1149,7 +1149,7 @@ void ConfigManager::on_result(NetQueryPtr res) {
|
||||
CHECK(dismiss_suggested_action_request_count_ >= promises.size());
|
||||
dismiss_suggested_action_request_count_ -= promises.size();
|
||||
|
||||
auto result_ptr = fetch_result<telegram_api::help_dismissSuggestion>(std::move(res));
|
||||
auto result_ptr = fetch_result<telegram_api::help_dismissSuggestion>(std::move(net_query));
|
||||
if (result_ptr.is_error()) {
|
||||
fail_promises(promises, result_ptr.move_as_error());
|
||||
return;
|
||||
@ -1163,7 +1163,7 @@ void ConfigManager::on_result(NetQueryPtr res) {
|
||||
if (token == 3 || token == 4) {
|
||||
is_set_content_settings_request_sent_ = false;
|
||||
bool ignore_sensitive_content_restrictions = (token == 4);
|
||||
auto result_ptr = fetch_result<telegram_api::account_setContentSettings>(std::move(res));
|
||||
auto result_ptr = fetch_result<telegram_api::account_setContentSettings>(std::move(net_query));
|
||||
if (result_ptr.is_error()) {
|
||||
fail_promises(set_content_settings_queries_[ignore_sensitive_content_restrictions], result_ptr.move_as_error());
|
||||
} else {
|
||||
@ -1185,7 +1185,7 @@ void ConfigManager::on_result(NetQueryPtr res) {
|
||||
return;
|
||||
}
|
||||
if (token == 2) {
|
||||
auto result_ptr = fetch_result<telegram_api::account_getContentSettings>(std::move(res));
|
||||
auto result_ptr = fetch_result<telegram_api::account_getContentSettings>(std::move(net_query));
|
||||
if (result_ptr.is_error()) {
|
||||
fail_promises(get_content_settings_queries_, result_ptr.move_as_error());
|
||||
return;
|
||||
@ -1204,7 +1204,7 @@ void ConfigManager::on_result(NetQueryPtr res) {
|
||||
auto unit_promises = std::move(reget_app_config_queries_);
|
||||
reget_app_config_queries_.clear();
|
||||
CHECK(!promises.empty() || !unit_promises.empty());
|
||||
auto result_ptr = fetch_result<telegram_api::help_getAppConfig>(std::move(res));
|
||||
auto result_ptr = fetch_result<telegram_api::help_getAppConfig>(std::move(net_query));
|
||||
if (result_ptr.is_error()) {
|
||||
fail_promises(promises, result_ptr.error().clone());
|
||||
fail_promises(unit_promises, result_ptr.move_as_error());
|
||||
@ -1240,7 +1240,7 @@ void ConfigManager::on_result(NetQueryPtr res) {
|
||||
CHECK(token == 8 || token == 9);
|
||||
CHECK(config_sent_cnt_ > 0);
|
||||
config_sent_cnt_--;
|
||||
auto r_config = fetch_result<telegram_api::help_getConfig>(std::move(res));
|
||||
auto r_config = fetch_result<telegram_api::help_getConfig>(std::move(net_query));
|
||||
if (r_config.is_error()) {
|
||||
if (!G()->close_flag()) {
|
||||
LOG(WARNING) << "Failed to get config: " << r_config.error();
|
||||
|
@ -147,7 +147,7 @@ class ConfigManager final : public NetQueryCallback {
|
||||
void loop() final;
|
||||
void try_stop();
|
||||
|
||||
void on_result(NetQueryPtr res) final;
|
||||
void on_result(NetQueryPtr net_query) final;
|
||||
|
||||
void request_config_from_dc_impl(DcId dc_id, bool reopen_sessions);
|
||||
void process_config(tl_object_ptr<telegram_api::config> config);
|
||||
|
@ -179,31 +179,31 @@ void PhoneNumberManager::process_check_code_result(Result<bool> &&result) {
|
||||
on_query_ok();
|
||||
}
|
||||
|
||||
void PhoneNumberManager::on_check_code_result(NetQueryPtr &result) {
|
||||
void PhoneNumberManager::on_check_code_result(NetQueryPtr &&net_query) {
|
||||
switch (type_) {
|
||||
case Type::ChangePhone:
|
||||
return process_check_code_result(fetch_result<telegram_api::account_changePhone>(result->ok()));
|
||||
return process_check_code_result(fetch_result<telegram_api::account_changePhone>(net_query->ok()));
|
||||
case Type::VerifyPhone:
|
||||
return process_check_code_result(fetch_result<telegram_api::account_verifyPhone>(result->ok()));
|
||||
return process_check_code_result(fetch_result<telegram_api::account_verifyPhone>(net_query->ok()));
|
||||
case Type::ConfirmPhone:
|
||||
return process_check_code_result(fetch_result<telegram_api::account_confirmPhone>(result->ok()));
|
||||
return process_check_code_result(fetch_result<telegram_api::account_confirmPhone>(net_query->ok()));
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
void PhoneNumberManager::on_send_code_result(NetQueryPtr &result) {
|
||||
void PhoneNumberManager::on_send_code_result(NetQueryPtr &&net_query) {
|
||||
auto r_sent_code = [&] {
|
||||
switch (type_) {
|
||||
case Type::ChangePhone:
|
||||
return fetch_result<telegram_api::account_sendChangePhoneCode>(result->ok());
|
||||
return fetch_result<telegram_api::account_sendChangePhoneCode>(net_query->ok());
|
||||
case Type::VerifyPhone:
|
||||
return fetch_result<telegram_api::account_sendVerifyPhoneCode>(result->ok());
|
||||
return fetch_result<telegram_api::account_sendVerifyPhoneCode>(net_query->ok());
|
||||
case Type::ConfirmPhone:
|
||||
return fetch_result<telegram_api::account_sendConfirmPhoneCode>(result->ok());
|
||||
return fetch_result<telegram_api::account_sendConfirmPhoneCode>(net_query->ok());
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return fetch_result<telegram_api::account_sendChangePhoneCode>(result->ok());
|
||||
return fetch_result<telegram_api::account_sendChangePhoneCode>(net_query->ok());
|
||||
}
|
||||
}();
|
||||
if (r_sent_code.is_error()) {
|
||||
@ -233,32 +233,34 @@ void PhoneNumberManager::on_send_code_result(NetQueryPtr &result) {
|
||||
on_query_ok();
|
||||
}
|
||||
|
||||
void PhoneNumberManager::on_result(NetQueryPtr result) {
|
||||
void PhoneNumberManager::on_result(NetQueryPtr net_query) {
|
||||
SCOPE_EXIT {
|
||||
result->clear();
|
||||
net_query->clear();
|
||||
};
|
||||
NetQueryType type = NetQueryType::None;
|
||||
if (result->id() == net_query_id_) {
|
||||
if (net_query->id() == net_query_id_) {
|
||||
net_query_id_ = 0;
|
||||
type = net_query_type_;
|
||||
net_query_type_ = NetQueryType::None;
|
||||
if (result->is_error()) {
|
||||
if (net_query->is_error()) {
|
||||
if (query_id_ != 0) {
|
||||
on_query_error(result->move_as_error());
|
||||
on_query_error(net_query->move_as_error());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case NetQueryType::None:
|
||||
result->ignore();
|
||||
net_query->ignore();
|
||||
break;
|
||||
case NetQueryType::SendCode:
|
||||
on_send_code_result(result);
|
||||
on_send_code_result(std::move(net_query));
|
||||
break;
|
||||
case NetQueryType::CheckCode:
|
||||
on_check_code_result(result);
|
||||
on_check_code_result(std::move(net_query));
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,11 +64,11 @@ class PhoneNumberManager final : public NetActor {
|
||||
|
||||
void process_check_code_result(Result<bool> &&result);
|
||||
|
||||
void on_result(NetQueryPtr result) final;
|
||||
void on_result(NetQueryPtr net_query) final;
|
||||
|
||||
void on_send_code_result(NetQueryPtr &result);
|
||||
void on_send_code_result(NetQueryPtr &&net_query);
|
||||
|
||||
void on_check_code_result(NetQueryPtr &result);
|
||||
void on_check_code_result(NetQueryPtr &&net_query);
|
||||
|
||||
void tear_down() final;
|
||||
};
|
||||
|
@ -102,19 +102,19 @@ void DcAuthManager::update_auth_key_state() {
|
||||
loop();
|
||||
}
|
||||
|
||||
void DcAuthManager::on_result(NetQueryPtr result) {
|
||||
void DcAuthManager::on_result(NetQueryPtr net_query) {
|
||||
auto dc_id = narrow_cast<int32>(get_link_token());
|
||||
auto &dc = get_dc(dc_id);
|
||||
CHECK(dc.wait_id == result->id());
|
||||
CHECK(dc.wait_id == net_query->id());
|
||||
dc.wait_id = std::numeric_limits<decltype(dc.wait_id)>::max();
|
||||
switch (dc.state) {
|
||||
case DcInfo::State::Import: {
|
||||
if (result->is_error()) {
|
||||
LOG(WARNING) << "DC auth_exportAuthorization error: " << result->error();
|
||||
if (net_query->is_error()) {
|
||||
LOG(WARNING) << "DC auth_exportAuthorization error: " << net_query->error();
|
||||
dc.state = DcInfo::State::Export;
|
||||
break;
|
||||
}
|
||||
auto r_result_auth_exported = fetch_result<telegram_api::auth_exportAuthorization>(result->ok());
|
||||
auto r_result_auth_exported = fetch_result<telegram_api::auth_exportAuthorization>(net_query->ok());
|
||||
if (r_result_auth_exported.is_error()) {
|
||||
LOG(WARNING) << "Failed to parse result to auth_exportAuthorization: " << r_result_auth_exported.error();
|
||||
dc.state = DcInfo::State::Export;
|
||||
@ -126,12 +126,12 @@ void DcAuthManager::on_result(NetQueryPtr result) {
|
||||
break;
|
||||
}
|
||||
case DcInfo::State::BeforeOk: {
|
||||
if (result->is_error()) {
|
||||
LOG(WARNING) << "DC authImport error: " << result->error();
|
||||
if (net_query->is_error()) {
|
||||
LOG(WARNING) << "DC authImport error: " << net_query->error();
|
||||
dc.state = DcInfo::State::Export;
|
||||
break;
|
||||
}
|
||||
auto result_auth = fetch_result<telegram_api::auth_importAuthorization>(result->ok());
|
||||
auto result_auth = fetch_result<telegram_api::auth_importAuthorization>(net_query->ok());
|
||||
if (result_auth.is_error()) {
|
||||
LOG(WARNING) << "Failed to parse result to auth_importAuthorization: " << result_auth.error();
|
||||
dc.state = DcInfo::State::Export;
|
||||
@ -143,7 +143,7 @@ void DcAuthManager::on_result(NetQueryPtr result) {
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
result->clear();
|
||||
net_query->clear();
|
||||
loop();
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ class DcAuthManager final : public NetQueryCallback {
|
||||
|
||||
void update_auth_key_state();
|
||||
|
||||
void on_result(NetQueryPtr result) final;
|
||||
void on_result(NetQueryPtr net_query) final;
|
||||
void dc_loop(DcInfo &dc);
|
||||
|
||||
void destroy_loop();
|
||||
|
Loading…
Reference in New Issue
Block a user