Add td_api::sendPhoneNumberFirebaseSms.
This commit is contained in:
parent
25958fb406
commit
3620b06df2
@ -9773,6 +9773,10 @@ setBusinessStartPage start_page:inputBusinessStartPage = Ok;
|
||||
//@type Type of the request for which the code is sent
|
||||
sendPhoneNumberCode phone_number:string settings:phoneNumberAuthenticationSettings type:PhoneNumberCodeType = AuthenticationCodeInfo;
|
||||
|
||||
//@description Sends Firebase Authentication SMS to the specified phone number. Works only when received a code of the type authenticationCodeTypeFirebaseAndroid or authenticationCodeTypeFirebaseIos
|
||||
//@token SafetyNet Attestation API token for the Android application, or secret from push notification for the iOS application
|
||||
sendPhoneNumberFirebaseSms token: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;
|
||||
|
||||
|
@ -53,6 +53,31 @@ class SendCodeQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class RequestFirebaseSmsQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
public:
|
||||
explicit RequestFirebaseSmsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(const telegram_api::auth_requestFirebaseSms &query) {
|
||||
send_query(G()->net_query_creator().create(query));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::auth_requestFirebaseSms>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class ChangePhoneQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
@ -222,6 +247,14 @@ void PhoneNumberManager::set_phone_number(string phone_number,
|
||||
}
|
||||
}
|
||||
|
||||
void PhoneNumberManager::send_firebase_sms(const string &token, Promise<Unit> &&promise) {
|
||||
if (state_ != State::WaitCode) {
|
||||
return promise.set_error(Status::Error(400, "Can't send Firebase SMS"));
|
||||
}
|
||||
|
||||
td_->create_handler<RequestFirebaseSmsQuery>(std::move(promise))->send(send_code_helper_.request_firebase_sms(token));
|
||||
}
|
||||
|
||||
void PhoneNumberManager::resend_authentication_code(
|
||||
Promise<td_api::object_ptr<td_api::authenticationCodeInfo>> &&promise) {
|
||||
if (state_ != State::WaitCode) {
|
||||
|
@ -27,6 +27,8 @@ class PhoneNumberManager final : public Actor {
|
||||
td_api::object_ptr<td_api::PhoneNumberCodeType> type,
|
||||
Promise<td_api::object_ptr<td_api::authenticationCodeInfo>> &&promise);
|
||||
|
||||
void send_firebase_sms(const string &token, Promise<Unit> &&promise);
|
||||
|
||||
void resend_authentication_code(Promise<td_api::object_ptr<td_api::authenticationCodeInfo>> &&promise);
|
||||
|
||||
void check_code(string code, Promise<Unit> &&promise);
|
||||
|
@ -4618,6 +4618,13 @@ void Td::on_request(uint64 id, td_api::sendPhoneNumberCode &request) {
|
||||
std::move(request.type_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::sendPhoneNumberFirebaseSms &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.token_);
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
phone_number_manager_->send_firebase_sms(std::move(request.token_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::resendPhoneNumberCode &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
|
@ -569,6 +569,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::sendPhoneNumberCode &request);
|
||||
|
||||
void on_request(uint64 id, td_api::sendPhoneNumberFirebaseSms &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::resendPhoneNumberCode &request);
|
||||
|
||||
void on_request(uint64 id, td_api::checkPhoneNumberCode &request);
|
||||
|
@ -2726,6 +2726,8 @@ class CliClient final : public Actor {
|
||||
get_args(args, hash, phone_number);
|
||||
send_request(td_api::make_object<td_api::sendPhoneNumberCode>(
|
||||
phone_number, nullptr, td_api::make_object<td_api::phoneNumberCodeTypeConfirmOwnership>(hash)));
|
||||
} else if (op == "spnfs") {
|
||||
send_request(td_api::make_object<td_api::sendPhoneNumberFirebaseSms>(args));
|
||||
} else if (op == "rpnc") {
|
||||
send_request(td_api::make_object<td_api::resendPhoneNumberCode>());
|
||||
} else if (op == "cpnc") {
|
||||
|
Loading…
Reference in New Issue
Block a user