mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
no message
This commit is contained in:
@@ -246,7 +246,13 @@ public struct EncryptedSecureIdForm {
|
||||
|
||||
public func requestSecureIdForm(postbox: Postbox, network: Network, peerId: PeerId, scope: String, publicKey: String) -> Signal<EncryptedSecureIdForm, RequestSecureIdFormError> {
|
||||
if peerId.namespace != Namespaces.Peer.CloudUser {
|
||||
return .fail(.serverError("PEER IS NOT A BOT"))
|
||||
return .fail(.serverError("BOT_INVALID"))
|
||||
}
|
||||
if scope.isEmpty {
|
||||
return .fail(.serverError("SCOPE_EMPTY"))
|
||||
}
|
||||
if publicKey.isEmpty {
|
||||
return .fail(.serverError("PUBLIC_KEY_REQUIRED"))
|
||||
}
|
||||
return network.request(Api.functions.account.getAuthorizationForm(botId: peerId.id, scope: scope, publicKey: publicKey))
|
||||
|> mapError { error -> RequestSecureIdFormError in
|
||||
@@ -256,7 +262,6 @@ public func requestSecureIdForm(postbox: Postbox, network: Network, peerId: Peer
|
||||
default:
|
||||
return .serverError(error.errorDescription)
|
||||
}
|
||||
|
||||
}
|
||||
|> mapToSignal { result -> Signal<EncryptedSecureIdForm, RequestSecureIdFormError> in
|
||||
return postbox.transaction { transaction -> EncryptedSecureIdForm in
|
||||
|
||||
@@ -12,6 +12,7 @@ import Foundation
|
||||
public enum SaveSecureIdValueError {
|
||||
case generic
|
||||
case verificationRequired
|
||||
case versionOutdated
|
||||
}
|
||||
|
||||
struct EncryptedSecureData {
|
||||
@@ -226,11 +227,15 @@ public func saveSecureIdValue(postbox: Postbox, network: Network, context: Secur
|
||||
}
|
||||
let save = network.request(Api.functions.account.saveSecureValue(value: inputValue, secureSecretId: context.id))
|
||||
|> mapError { error -> SaveSecureIdValueError in
|
||||
if error.errorDescription == "PHONE_VERIFICATION_NEEDED" || error.errorDescription == "EMAIL_VERIFICATION_NEEDED" {
|
||||
switch error.errorDescription {
|
||||
case "PHONE_VERIFICATION_NEEDED", "EMAIL_VERIFICATION_NEEDED":
|
||||
return .verificationRequired
|
||||
}
|
||||
case "APP_VERSION_OUTDATED":
|
||||
return .versionOutdated
|
||||
default:
|
||||
return .generic
|
||||
}
|
||||
}
|
||||
|> mapToSignal { result -> Signal<SecureIdValueWithContext, SaveSecureIdValueError> in
|
||||
guard let parsedValue = parseSecureValue(context: context, value: result, errors: []) else {
|
||||
return .fail(.generic)
|
||||
@@ -255,13 +260,19 @@ public func saveSecureIdValue(postbox: Postbox, network: Network, context: Secur
|
||||
|
||||
public enum DeleteSecureIdValueError {
|
||||
case generic
|
||||
case versionOutdated
|
||||
}
|
||||
|
||||
public func deleteSecureIdValues(network: Network, keys: Set<SecureIdValueKey>) -> Signal<Void, DeleteSecureIdValueError> {
|
||||
return network.request(Api.functions.account.deleteSecureValue(types: keys.map(apiSecureValueType(key:))))
|
||||
|> mapError { _ -> DeleteSecureIdValueError in
|
||||
|> mapError { error -> DeleteSecureIdValueError in
|
||||
switch error.errorDescription {
|
||||
case "APP_VERSION_OUTDATED":
|
||||
return .versionOutdated
|
||||
default:
|
||||
return .generic
|
||||
}
|
||||
}
|
||||
|> mapToSignal { _ -> Signal<Void, DeleteSecureIdValueError> in
|
||||
return .complete()
|
||||
}
|
||||
@@ -308,6 +319,7 @@ public func dropSecureId(network: Network, currentPassword: String) -> Signal<Vo
|
||||
|
||||
public enum GetAllSecureIdValuesError {
|
||||
case generic
|
||||
case versionOutdated
|
||||
}
|
||||
|
||||
public struct EncryptedAllSecureIdValues {
|
||||
@@ -316,9 +328,14 @@ public struct EncryptedAllSecureIdValues {
|
||||
|
||||
public func getAllSecureIdValues(network: Network) -> Signal<EncryptedAllSecureIdValues, GetAllSecureIdValuesError> {
|
||||
return network.request(Api.functions.account.getAllSecureValues())
|
||||
|> mapError { _ -> GetAllSecureIdValuesError in
|
||||
|> mapError { error -> GetAllSecureIdValuesError in
|
||||
switch error.errorDescription {
|
||||
case "APP_VERSION_OUTDATED":
|
||||
return .versionOutdated
|
||||
default:
|
||||
return .generic
|
||||
}
|
||||
}
|
||||
|> map { result in
|
||||
return EncryptedAllSecureIdValues(values: result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user