Add td_api::ResendCodeReason.
This commit is contained in:
parent
6111abc0a1
commit
6d780d02af
@ -4109,6 +4109,16 @@ chatBoostSlot slot_id:int32 currently_boosted_chat_id:int53 start_date:int32 exp
|
||||
chatBoostSlots slots:vector<chatBoostSlot> = ChatBoostSlots;
|
||||
|
||||
|
||||
//@class ResendCodeReason @description Describes the reason why a code needs to be re-sent
|
||||
|
||||
//@description The user requested to resend the code
|
||||
resendCodeReasonUserRequest = ResendCodeReason;
|
||||
|
||||
//@description The code is resent, because device verification has failed
|
||||
//@error_message Cause of the verification failure, for example, PLAY_SERVICES_NOT_AVAILABLE, APNS_RECEIVE_TIMEOUT, APNS_INIT_FAILED, etc.
|
||||
resendCodeReasonVerificationFailed error_message:string = ResendCodeReason;
|
||||
|
||||
|
||||
//@class CallDiscardReason @description Describes the reason why a call was discarded
|
||||
|
||||
//@description The call wasn't discarded, or the reason is unknown
|
||||
@ -7503,9 +7513,10 @@ setAuthenticationPhoneNumber phone_number:string settings:phoneNumberAuthenticat
|
||||
//@description Sets the email address of the user and sends an authentication code to the email address. Works only when the current authorization state is authorizationStateWaitEmailAddress @email_address The email address of the user
|
||||
setAuthenticationEmailAddress email_address:string = Ok;
|
||||
|
||||
//@description Resends an authentication code to the user. Works only when the current authorization state is authorizationStateWaitCode, the next_code_type of the result is not null and the server-specified timeout has passed,
|
||||
//-or when the current authorization state is authorizationStateWaitEmailCode
|
||||
resendAuthenticationCode = Ok;
|
||||
//@description Resends an authentication code to the user. Works only when the current authorization state is authorizationStateWaitCode, the next_code_type of the result is not null
|
||||
//-and the server-specified timeout has passed, or when the current authorization state is authorizationStateWaitEmailCode
|
||||
//@reason Reason of code resending; pass null if unknown
|
||||
resendAuthenticationCode reason:ResendCodeReason = Ok;
|
||||
|
||||
//@description Checks the authentication of an email address. Works only when the current authorization state is authorizationStateWaitEmailCode @code Email address authentication to check
|
||||
checkAuthenticationEmailCode code:EmailAddressAuthentication = Ok;
|
||||
@ -9953,7 +9964,8 @@ sendPhoneNumberFirebaseSms token:string = Ok;
|
||||
reportPhoneNumberCodeMissing mobile_network_code:string = Ok;
|
||||
|
||||
//@description Resends the authentication code sent to a phone number. Works only if the previously received authenticationCodeInfo next_code_type was not null and the server-specified timeout has passed
|
||||
resendPhoneNumberCode = AuthenticationCodeInfo;
|
||||
//@reason Reason of code resending; pass null if unknown
|
||||
resendPhoneNumberCode reason:ResendCodeReason = AuthenticationCodeInfo;
|
||||
|
||||
//@description Check the authentication code and completes the request for which the code was sent if appropriate @code Authentication code to check
|
||||
checkPhoneNumberCode code:string = Ok;
|
||||
|
@ -568,7 +568,7 @@ void AuthManager::set_email_address(uint64 query_id, string email_address) {
|
||||
G()->net_query_creator().create_unauth(send_code_helper_.send_verify_email_code(email_address_)));
|
||||
}
|
||||
|
||||
void AuthManager::resend_authentication_code(uint64 query_id) {
|
||||
void AuthManager::resend_authentication_code(uint64 query_id, td_api::object_ptr<td_api::ResendCodeReason> &&reason) {
|
||||
if (state_ != State::WaitCode) {
|
||||
if (state_ == State::WaitEmailCode) {
|
||||
on_new_query(query_id);
|
||||
@ -580,7 +580,7 @@ void AuthManager::resend_authentication_code(uint64 query_id) {
|
||||
return on_query_error(query_id, Status::Error(400, "Call to resendAuthenticationCode unexpected"));
|
||||
}
|
||||
|
||||
auto r_resend_code = send_code_helper_.resend_code();
|
||||
auto r_resend_code = send_code_helper_.resend_code(std::move(reason));
|
||||
if (r_resend_code.is_error()) {
|
||||
return on_query_error(query_id, r_resend_code.move_as_error());
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class AuthManager final : public NetActor {
|
||||
void set_firebase_token(uint64 query_id, string token);
|
||||
void report_missing_code(uint64 query_id, string mobile_network_code);
|
||||
void set_email_address(uint64 query_id, string email_address);
|
||||
void resend_authentication_code(uint64 query_id);
|
||||
void resend_authentication_code(uint64 query_id, td_api::object_ptr<td_api::ResendCodeReason> &&reason);
|
||||
void check_email_code(uint64 query_id, EmailVerification &&code);
|
||||
void reset_email_address(uint64 query_id);
|
||||
void check_code(uint64 query_id, string code);
|
||||
|
@ -290,12 +290,13 @@ void PhoneNumberManager::report_missing_code(const string &mobile_network_code,
|
||||
}
|
||||
|
||||
void PhoneNumberManager::resend_authentication_code(
|
||||
td_api::object_ptr<td_api::ResendCodeReason> &&reason,
|
||||
Promise<td_api::object_ptr<td_api::authenticationCodeInfo>> &&promise) {
|
||||
if (state_ != State::WaitCode) {
|
||||
return promise.set_error(Status::Error(400, "Can't resend code"));
|
||||
}
|
||||
|
||||
auto r_resend_code = send_code_helper_.resend_code();
|
||||
auto r_resend_code = send_code_helper_.resend_code(std::move(reason));
|
||||
if (r_resend_code.is_error()) {
|
||||
return promise.set_error(r_resend_code.move_as_error());
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ class PhoneNumberManager final : public Actor {
|
||||
|
||||
void report_missing_code(const string &mobile_network_code, Promise<Unit> &&promise);
|
||||
|
||||
void resend_authentication_code(Promise<td_api::object_ptr<td_api::authenticationCodeInfo>> &&promise);
|
||||
void resend_authentication_code(td_api::object_ptr<td_api::ResendCodeReason> &&reason,
|
||||
Promise<td_api::object_ptr<td_api::authenticationCodeInfo>> &&promise);
|
||||
|
||||
void check_code(string code, Promise<Unit> &&promise);
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
//
|
||||
#include "td/telegram/SendCodeHelper.h"
|
||||
|
||||
#include "td/telegram/misc.h"
|
||||
|
||||
#include "td/utils/base64.h"
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -43,12 +45,20 @@ td_api::object_ptr<td_api::authenticationCodeInfo> SendCodeHelper::get_authentic
|
||||
max(static_cast<int32>(next_code_timestamp_ - Time::now() + 1 - 1e-9), 0));
|
||||
}
|
||||
|
||||
Result<telegram_api::auth_resendCode> SendCodeHelper::resend_code() const {
|
||||
Result<telegram_api::auth_resendCode> SendCodeHelper::resend_code(
|
||||
td_api::object_ptr<td_api::ResendCodeReason> &&reason) const {
|
||||
if (next_code_info_.type == AuthenticationCodeInfo::Type::None) {
|
||||
return Status::Error(400, "Authentication code can't be resend");
|
||||
}
|
||||
int32 flags = 0;
|
||||
return telegram_api::auth_resendCode(flags, phone_number_, phone_code_hash_, string());
|
||||
string reason_str;
|
||||
if (reason->get_id() == td_api::resendCodeReasonVerificationFailed::ID) {
|
||||
reason_str = std::move(static_cast<td_api::resendCodeReasonVerificationFailed *>(reason.get())->error_message_);
|
||||
}
|
||||
if (!reason_str.empty() && clean_input_string(reason_str)) {
|
||||
flags |= telegram_api::auth_resendCode::REASON_MASK;
|
||||
}
|
||||
return telegram_api::auth_resendCode(flags, phone_number_, phone_code_hash_, reason_str);
|
||||
}
|
||||
|
||||
telegram_api::object_ptr<telegram_api::codeSettings> SendCodeHelper::get_input_code_settings(const Settings &settings) {
|
||||
|
@ -25,7 +25,7 @@ class SendCodeHelper {
|
||||
|
||||
td_api::object_ptr<td_api::authenticationCodeInfo> get_authentication_code_info_object() const;
|
||||
|
||||
Result<telegram_api::auth_resendCode> resend_code() const;
|
||||
Result<telegram_api::auth_resendCode> resend_code(td_api::object_ptr<td_api::ResendCodeReason> &&reason) const;
|
||||
|
||||
using Settings = td_api::object_ptr<td_api::phoneNumberAuthenticationSettings>;
|
||||
|
||||
|
@ -4150,8 +4150,8 @@ void Td::on_request(uint64 id, td_api::setAuthenticationEmailAddress &request) {
|
||||
send_closure(auth_manager_actor_, &AuthManager::set_email_address, id, std::move(request.email_address_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::resendAuthenticationCode &request) {
|
||||
send_closure(auth_manager_actor_, &AuthManager::resend_authentication_code, id);
|
||||
void Td::on_request(uint64 id, td_api::resendAuthenticationCode &request) {
|
||||
send_closure(auth_manager_actor_, &AuthManager::resend_authentication_code, id, std::move(request.reason_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::checkAuthenticationEmailCode &request) {
|
||||
@ -4542,10 +4542,10 @@ void Td::on_request(uint64 id, td_api::reportPhoneNumberCodeMissing &request) {
|
||||
phone_number_manager_->report_missing_code(std::move(request.mobile_network_code_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::resendPhoneNumberCode &request) {
|
||||
void Td::on_request(uint64 id, td_api::resendPhoneNumberCode &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
phone_number_manager_->resend_authentication_code(std::move(promise));
|
||||
phone_number_manager_->resend_authentication_code(std::move(request.reason_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::checkPhoneNumberCode &request) {
|
||||
|
@ -483,7 +483,7 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::setAuthenticationEmailAddress &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::resendAuthenticationCode &request);
|
||||
void on_request(uint64 id, td_api::resendAuthenticationCode &request);
|
||||
|
||||
void on_request(uint64 id, td_api::checkAuthenticationEmailCode &request);
|
||||
|
||||
@ -575,7 +575,7 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::reportPhoneNumberCodeMissing &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::resendPhoneNumberCode &request);
|
||||
void on_request(uint64 id, td_api::resendPhoneNumberCode &request);
|
||||
|
||||
void on_request(uint64 id, td_api::checkPhoneNumberCode &request);
|
||||
|
||||
|
@ -2477,7 +2477,7 @@ class CliClient final : public Actor {
|
||||
} else if (op == "sae" || op == "saea") {
|
||||
send_request(td_api::make_object<td_api::setAuthenticationEmailAddress>(args));
|
||||
} else if (op == "rac") {
|
||||
send_request(td_api::make_object<td_api::resendAuthenticationCode>());
|
||||
send_request(td_api::make_object<td_api::resendAuthenticationCode>(nullptr));
|
||||
} else if (op == "sdek") {
|
||||
send_request(td_api::make_object<td_api::setDatabaseEncryptionKey>(args));
|
||||
} else if (op == "caec") {
|
||||
@ -2778,7 +2778,7 @@ class CliClient final : public Actor {
|
||||
} else if (op == "rpncm") {
|
||||
send_request(td_api::make_object<td_api::reportPhoneNumberCodeMissing>(args));
|
||||
} else if (op == "rpnc") {
|
||||
send_request(td_api::make_object<td_api::resendPhoneNumberCode>());
|
||||
send_request(td_api::make_object<td_api::resendPhoneNumberCode>(nullptr));
|
||||
} else if (op == "cpnc") {
|
||||
send_request(td_api::make_object<td_api::checkPhoneNumberCode>(args));
|
||||
} else if (op == "gco") {
|
||||
|
Loading…
Reference in New Issue
Block a user