Add td_api::cancelRecoveryEmailAddressVerification.

This commit is contained in:
levlam 2024-01-11 14:51:29 +03:00
parent 562374088c
commit 2ff1a93d5b
6 changed files with 26 additions and 0 deletions

View File

@ -6946,6 +6946,9 @@ checkRecoveryEmailAddressCode code:string = PasswordState;
//@description Resends the 2-step verification recovery email address verification code
resendRecoveryEmailAddressCode = PasswordState;
//@description Cancels verification of the 2-step verification recovery email address
cancelRecoveryEmailAddressVerification = PasswordState;
//@description Requests to send a 2-step verification password recovery code to an email address that was previously set up
requestPasswordRecovery = EmailAddressAuthenticationCodeInfo;

View File

@ -462,6 +462,18 @@ void PasswordManager::resend_recovery_email_address_code(Promise<State> promise)
}));
}
void PasswordManager::cancel_recovery_email_address_verification(Promise<State> promise) {
auto query = G()->net_query_creator().create(telegram_api::account_cancelPasswordEmail());
send_with_promise(std::move(query), PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise)](
Result<NetQueryPtr> r_query) mutable {
auto r_result = fetch_result<telegram_api::account_cancelPasswordEmail>(std::move(r_query));
if (r_result.is_error() && r_result.error().message() != "EMAIL_HASH_EXPIRED") {
return promise.set_error(r_result.move_as_error());
}
send_closure(actor_id, &PasswordManager::get_state, std::move(promise));
}));
}
void PasswordManager::send_email_address_verification_code(string email, Promise<SentEmailCode> promise) {
last_verified_email_address_ = email;
auto query = G()->net_query_creator().create(telegram_api::account_sendVerifyEmailCode(

View File

@ -80,6 +80,7 @@ class PasswordManager final : public NetQueryCallback {
void get_recovery_email_address(string password, Promise<tl_object_ptr<td_api::recoveryEmailAddress>> promise);
void check_recovery_email_address_code(string code, Promise<State> promise);
void resend_recovery_email_address_code(Promise<State> promise);
void cancel_recovery_email_address_verification(Promise<State> promise);
void send_email_address_verification_code(string email, Promise<SentEmailCode> promise);
void resend_email_address_verification_code(Promise<SentEmailCode> promise);

View File

@ -4378,6 +4378,12 @@ void Td::on_request(uint64 id, const td_api::resendRecoveryEmailAddressCode &req
send_closure(password_manager_, &PasswordManager::resend_recovery_email_address_code, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::cancelRecoveryEmailAddressVerification &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
send_closure(password_manager_, &PasswordManager::cancel_recovery_email_address_verification, std::move(promise));
}
void Td::on_request(uint64 id, td_api::requestPasswordRecovery &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();

View File

@ -511,6 +511,8 @@ class Td final : public Actor {
void on_request(uint64 id, const td_api::resendRecoveryEmailAddressCode &request);
void on_request(uint64 id, const td_api::cancelRecoveryEmailAddressVerification &request);
void on_request(uint64 id, td_api::requestPasswordRecovery &request);
void on_request(uint64 id, td_api::checkPasswordRecoveryCode &request);

View File

@ -2529,6 +2529,8 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::checkRecoveryEmailAddressCode>(args));
} else if (op == "rreac") {
send_request(td_api::make_object<td_api::resendRecoveryEmailAddressCode>());
} else if (op == "creav") {
send_request(td_api::make_object<td_api::cancelRecoveryEmailAddressVerification>());
} else if (op == "spncc") {
string hash;
string phone_number;