Simplify send_*_phone_code.

GitOrigin-RevId: 72b09f64fab527c8a2363bae72e0e40770f64a83
This commit is contained in:
levlam 2019-09-02 18:16:34 +03:00
parent ebf9f45eeb
commit eeaed834d1
4 changed files with 14 additions and 21 deletions

View File

@ -37,14 +37,9 @@ PhoneNumberManager::PhoneNumberManager(PhoneNumberManager::Type type, ActorShare
} }
template <class T> template <class T>
void PhoneNumberManager::process_send_code_result(uint64 query_id, T r_send_code) { void PhoneNumberManager::process_send_code_result(uint64 query_id, const T &send_code) {
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, G()->net_query_creator().create(create_storer(send_code)));
start_net_query(NetQueryType::SendCode, G()->net_query_creator().create(create_storer(r_send_code.move_as_ok())));
} }
void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number, Settings settings) { void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number, Settings settings) {

View File

@ -52,7 +52,7 @@ class PhoneNumberManager : public NetActor {
void start_net_query(NetQueryType net_query_type, NetQueryPtr net_query); void start_net_query(NetQueryType net_query_type, NetQueryPtr net_query);
template <class T> template <class T>
void process_send_code_result(uint64 query_id, T r_send_code); void process_send_code_result(uint64 query_id, const T &send_code);
template <class T> template <class T>
void send_new_check_code_query(const T &query); void send_new_check_code_query(const T &query);

View File

@ -65,19 +65,19 @@ Result<telegram_api::auth_sendCode> SendCodeHelper::send_code(Slice phone_number
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));
} }
Result<telegram_api::account_sendChangePhoneCode> SendCodeHelper::send_change_phone_code(Slice phone_number, telegram_api::account_sendChangePhoneCode SendCodeHelper::send_change_phone_code(Slice phone_number,
const Settings &settings) { const Settings &settings) {
phone_number_ = phone_number.str(); phone_number_ = phone_number.str();
return telegram_api::account_sendChangePhoneCode(phone_number_, get_input_code_settings(settings)); return telegram_api::account_sendChangePhoneCode(phone_number_, get_input_code_settings(settings));
} }
Result<telegram_api::account_sendVerifyPhoneCode> SendCodeHelper::send_verify_phone_code(Slice phone_number, telegram_api::account_sendVerifyPhoneCode SendCodeHelper::send_verify_phone_code(Slice phone_number,
const Settings &settings) { const Settings &settings) {
phone_number_ = phone_number.str(); phone_number_ = phone_number.str();
return telegram_api::account_sendVerifyPhoneCode(phone_number_, get_input_code_settings(settings)); return telegram_api::account_sendVerifyPhoneCode(phone_number_, get_input_code_settings(settings));
} }
Result<telegram_api::account_sendConfirmPhoneCode> SendCodeHelper::send_confirm_phone_code(const string &hash, telegram_api::account_sendConfirmPhoneCode SendCodeHelper::send_confirm_phone_code(const string &hash,
Slice phone_number, Slice phone_number,
const Settings &settings) { const Settings &settings) {
phone_number_ = phone_number.str(); phone_number_ = phone_number.str();

View File

@ -28,13 +28,11 @@ class SendCodeHelper {
Result<telegram_api::auth_sendCode> send_code(Slice phone_number, const Settings &settings, int32 api_id, Result<telegram_api::auth_sendCode> send_code(Slice phone_number, const Settings &settings, int32 api_id,
const string &api_hash); const string &api_hash);
Result<telegram_api::account_sendChangePhoneCode> send_change_phone_code(Slice phone_number, telegram_api::account_sendChangePhoneCode send_change_phone_code(Slice phone_number, const Settings &settings);
const Settings &settings);
Result<telegram_api::account_sendVerifyPhoneCode> send_verify_phone_code(Slice phone_number, telegram_api::account_sendVerifyPhoneCode send_verify_phone_code(Slice phone_number, const Settings &settings);
const Settings &settings);
Result<telegram_api::account_sendConfirmPhoneCode> send_confirm_phone_code(const string &hash, Slice phone_number, telegram_api::account_sendConfirmPhoneCode send_confirm_phone_code(const string &hash, Slice phone_number,
const Settings &settings); const Settings &settings);
Slice phone_number() const { Slice phone_number() const {