Simplify SendCodeHelper::send_code.
GitOrigin-RevId: c89daaa0958aebd4fc09cf9690369b80721cafb3
This commit is contained in:
parent
0594b9e795
commit
205e68bf8b
@ -261,21 +261,17 @@ void AuthManager::set_phone_number(uint64 query_id, string phone_number,
|
|||||||
other_user_ids_.clear();
|
other_user_ids_.clear();
|
||||||
was_qr_code_request_ = false;
|
was_qr_code_request_ = false;
|
||||||
|
|
||||||
auto r_send_code = send_code_helper_.send_code(phone_number, settings, api_id_, api_hash_);
|
if (send_code_helper_.phone_number() != phone_number) {
|
||||||
if (r_send_code.is_error()) {
|
|
||||||
send_code_helper_ = SendCodeHelper();
|
send_code_helper_ = SendCodeHelper();
|
||||||
terms_of_service_ = TermsOfService();
|
terms_of_service_ = TermsOfService();
|
||||||
r_send_code = send_code_helper_.send_code(phone_number, settings, api_id_, api_hash_);
|
|
||||||
if (r_send_code.is_error()) {
|
|
||||||
return on_query_error(query_id, r_send_code.move_as_error());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
on_new_query(query_id);
|
on_new_query(query_id);
|
||||||
|
|
||||||
start_net_query(NetQueryType::SendCode,
|
start_net_query(NetQueryType::SendCode,
|
||||||
G()->net_query_creator().create(create_storer(r_send_code.move_as_ok()), DcId::main(),
|
G()->net_query_creator().create(
|
||||||
NetQuery::Type::Common, NetQuery::AuthFlag::Off));
|
create_storer(send_code_helper_.send_code(phone_number, settings, api_id_, api_hash_)),
|
||||||
|
DcId::main(), NetQuery::Type::Common, NetQuery::AuthFlag::Off));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuthManager::resend_authentication_code(uint64 query_id) {
|
void AuthManager::resend_authentication_code(uint64 query_id) {
|
||||||
|
@ -53,11 +53,8 @@ telegram_api::object_ptr<telegram_api::codeSettings> SendCodeHelper::get_input_c
|
|||||||
false /*ignored*/);
|
false /*ignored*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<telegram_api::auth_sendCode> SendCodeHelper::send_code(Slice phone_number, const Settings &settings,
|
telegram_api::auth_sendCode SendCodeHelper::send_code(Slice phone_number, const Settings &settings, int32 api_id,
|
||||||
int32 api_id, const string &api_hash) {
|
const string &api_hash) {
|
||||||
if (!phone_number_.empty()) {
|
|
||||||
return Status::Error(8, "Can't change phone");
|
|
||||||
}
|
|
||||||
phone_number_ = phone_number.str();
|
phone_number_ = phone_number.str();
|
||||||
return telegram_api::auth_sendCode(phone_number_, api_id, api_hash, get_input_code_settings(settings));
|
return telegram_api::auth_sendCode(phone_number_, api_id, api_hash, get_input_code_settings(settings));
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@ class SendCodeHelper {
|
|||||||
|
|
||||||
using Settings = td_api::object_ptr<td_api::phoneNumberAuthenticationSettings>;
|
using Settings = td_api::object_ptr<td_api::phoneNumberAuthenticationSettings>;
|
||||||
|
|
||||||
Result<telegram_api::auth_sendCode> send_code(Slice phone_number, const Settings &settings, int32 api_id,
|
telegram_api::auth_sendCode send_code(Slice phone_number, const Settings &settings, int32 api_id,
|
||||||
const string &api_hash);
|
const string &api_hash);
|
||||||
|
|
||||||
telegram_api::account_sendChangePhoneCode send_change_phone_code(Slice phone_number, const Settings &settings);
|
telegram_api::account_sendChangePhoneCode send_change_phone_code(Slice phone_number, const Settings &settings);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user