Fix push in change number flow

This commit is contained in:
Ali
2023-11-14 16:41:10 +04:00
parent 38a43e97b7
commit bc576aab86
5 changed files with 79 additions and 37 deletions

View File

@@ -36,8 +36,21 @@ public enum RequestChangeAccountPhoneNumberVerificationError {
case generic
}
func _internal_requestChangeAccountPhoneNumberVerification(account: Account, phoneNumber: String) -> Signal<ChangeAccountPhoneNumberData, RequestChangeAccountPhoneNumberVerificationError> {
return account.network.request(Api.functions.account.sendChangePhoneCode(phoneNumber: phoneNumber, settings: .codeSettings(flags: 0, logoutTokens: nil, token: nil, appSandbox: nil)), automaticFloodWait: false)
func _internal_requestChangeAccountPhoneNumberVerification(account: Account, phoneNumber: String, pushNotificationConfiguration: AuthorizationCodePushNotificationConfiguration?, firebaseSecretStream: Signal<[String: String], NoError>) -> Signal<ChangeAccountPhoneNumberData, RequestChangeAccountPhoneNumberVerificationError> {
var flags: Int32 = 0
flags |= 1 << 5 //allowMissedCall
var token: String?
var appSandbox: Api.Bool?
if let pushNotificationConfiguration = pushNotificationConfiguration {
flags |= 1 << 7
flags |= 1 << 8
token = pushNotificationConfiguration.token
appSandbox = pushNotificationConfiguration.isSandbox ? .boolTrue : .boolFalse
}
return account.network.request(Api.functions.account.sendChangePhoneCode(phoneNumber: phoneNumber, settings: .codeSettings(flags: flags, logoutTokens: nil, token: token, appSandbox: appSandbox)), automaticFloodWait: false)
|> mapError { error -> RequestChangeAccountPhoneNumberVerificationError in
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
return .limitExceeded