mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-24 11:56:18 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
59 lines
1.8 KiB
Swift
59 lines
1.8 KiB
Swift
import Foundation
|
|
import SwiftSignalKit
|
|
import MtProtoKit
|
|
import TelegramApi
|
|
|
|
|
|
public enum ConfirmTwoStepRecoveryEmailError {
|
|
case invalidEmail
|
|
case invalidCode
|
|
case flood
|
|
case expired
|
|
case generic
|
|
}
|
|
|
|
func _internal_confirmTwoStepRecoveryEmail(network: Network, code: String) -> Signal<Never, ConfirmTwoStepRecoveryEmailError> {
|
|
return network.request(Api.functions.account.confirmPasswordEmail(code: code), automaticFloodWait: false)
|
|
|> mapError { error -> ConfirmTwoStepRecoveryEmailError in
|
|
if error.errorDescription == "EMAIL_INVALID" {
|
|
return .invalidEmail
|
|
} else if error.errorDescription == "CODE_INVALID" {
|
|
return .invalidCode
|
|
} else if error.errorDescription == "EMAIL_HASH_EXPIRED" {
|
|
return .expired
|
|
} else if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
|
return .flood
|
|
}
|
|
return .generic
|
|
}
|
|
|> ignoreValues
|
|
}
|
|
|
|
public enum ResendTwoStepRecoveryEmailError {
|
|
case flood
|
|
case generic
|
|
}
|
|
|
|
func _internal_resendTwoStepRecoveryEmail(network: Network) -> Signal<Never, ResendTwoStepRecoveryEmailError> {
|
|
return network.request(Api.functions.account.resendPasswordEmail(), automaticFloodWait: false)
|
|
|> mapError { error -> ResendTwoStepRecoveryEmailError in
|
|
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
|
return .flood
|
|
}
|
|
return .generic
|
|
}
|
|
|> ignoreValues
|
|
}
|
|
|
|
public enum CancelTwoStepRecoveryEmailError {
|
|
case generic
|
|
}
|
|
|
|
func _internal_cancelTwoStepRecoveryEmail(network: Network) -> Signal<Never, CancelTwoStepRecoveryEmailError> {
|
|
return network.request(Api.functions.account.cancelPasswordEmail(), automaticFloodWait: false)
|
|
|> mapError { _ -> CancelTwoStepRecoveryEmailError in
|
|
return .generic
|
|
}
|
|
|> ignoreValues
|
|
}
|