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,17 +246,22 @@ public struct EncryptedSecureIdForm {
|
|||||||
|
|
||||||
public func requestSecureIdForm(postbox: Postbox, network: Network, peerId: PeerId, scope: String, publicKey: String) -> Signal<EncryptedSecureIdForm, RequestSecureIdFormError> {
|
public func requestSecureIdForm(postbox: Postbox, network: Network, peerId: PeerId, scope: String, publicKey: String) -> Signal<EncryptedSecureIdForm, RequestSecureIdFormError> {
|
||||||
if peerId.namespace != Namespaces.Peer.CloudUser {
|
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))
|
return network.request(Api.functions.account.getAuthorizationForm(botId: peerId.id, scope: scope, publicKey: publicKey))
|
||||||
|> mapError { error -> RequestSecureIdFormError in
|
|> mapError { error -> RequestSecureIdFormError in
|
||||||
switch error.errorDescription {
|
switch error.errorDescription {
|
||||||
case "APP_VERSION_OUTDATED":
|
case "APP_VERSION_OUTDATED":
|
||||||
return .versionOutdated
|
return .versionOutdated
|
||||||
default:
|
default:
|
||||||
return .serverError(error.errorDescription)
|
return .serverError(error.errorDescription)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|> mapToSignal { result -> Signal<EncryptedSecureIdForm, RequestSecureIdFormError> in
|
|> mapToSignal { result -> Signal<EncryptedSecureIdForm, RequestSecureIdFormError> in
|
||||||
return postbox.transaction { transaction -> EncryptedSecureIdForm in
|
return postbox.transaction { transaction -> EncryptedSecureIdForm in
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import Foundation
|
|||||||
public enum SaveSecureIdValueError {
|
public enum SaveSecureIdValueError {
|
||||||
case generic
|
case generic
|
||||||
case verificationRequired
|
case verificationRequired
|
||||||
|
case versionOutdated
|
||||||
}
|
}
|
||||||
|
|
||||||
struct EncryptedSecureData {
|
struct EncryptedSecureData {
|
||||||
@@ -226,10 +227,14 @@ public func saveSecureIdValue(postbox: Postbox, network: Network, context: Secur
|
|||||||
}
|
}
|
||||||
let save = network.request(Api.functions.account.saveSecureValue(value: inputValue, secureSecretId: context.id))
|
let save = network.request(Api.functions.account.saveSecureValue(value: inputValue, secureSecretId: context.id))
|
||||||
|> mapError { error -> SaveSecureIdValueError in
|
|> mapError { error -> SaveSecureIdValueError in
|
||||||
if error.errorDescription == "PHONE_VERIFICATION_NEEDED" || error.errorDescription == "EMAIL_VERIFICATION_NEEDED" {
|
switch error.errorDescription {
|
||||||
return .verificationRequired
|
case "PHONE_VERIFICATION_NEEDED", "EMAIL_VERIFICATION_NEEDED":
|
||||||
|
return .verificationRequired
|
||||||
|
case "APP_VERSION_OUTDATED":
|
||||||
|
return .versionOutdated
|
||||||
|
default:
|
||||||
|
return .generic
|
||||||
}
|
}
|
||||||
return .generic
|
|
||||||
}
|
}
|
||||||
|> mapToSignal { result -> Signal<SecureIdValueWithContext, SaveSecureIdValueError> in
|
|> mapToSignal { result -> Signal<SecureIdValueWithContext, SaveSecureIdValueError> in
|
||||||
guard let parsedValue = parseSecureValue(context: context, value: result, errors: []) else {
|
guard let parsedValue = parseSecureValue(context: context, value: result, errors: []) else {
|
||||||
@@ -255,12 +260,18 @@ public func saveSecureIdValue(postbox: Postbox, network: Network, context: Secur
|
|||||||
|
|
||||||
public enum DeleteSecureIdValueError {
|
public enum DeleteSecureIdValueError {
|
||||||
case generic
|
case generic
|
||||||
|
case versionOutdated
|
||||||
}
|
}
|
||||||
|
|
||||||
public func deleteSecureIdValues(network: Network, keys: Set<SecureIdValueKey>) -> Signal<Void, DeleteSecureIdValueError> {
|
public func deleteSecureIdValues(network: Network, keys: Set<SecureIdValueKey>) -> Signal<Void, DeleteSecureIdValueError> {
|
||||||
return network.request(Api.functions.account.deleteSecureValue(types: keys.map(apiSecureValueType(key:))))
|
return network.request(Api.functions.account.deleteSecureValue(types: keys.map(apiSecureValueType(key:))))
|
||||||
|> mapError { _ -> DeleteSecureIdValueError in
|
|> mapError { error -> DeleteSecureIdValueError in
|
||||||
return .generic
|
switch error.errorDescription {
|
||||||
|
case "APP_VERSION_OUTDATED":
|
||||||
|
return .versionOutdated
|
||||||
|
default:
|
||||||
|
return .generic
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|> mapToSignal { _ -> Signal<Void, DeleteSecureIdValueError> in
|
|> mapToSignal { _ -> Signal<Void, DeleteSecureIdValueError> in
|
||||||
return .complete()
|
return .complete()
|
||||||
@@ -308,6 +319,7 @@ public func dropSecureId(network: Network, currentPassword: String) -> Signal<Vo
|
|||||||
|
|
||||||
public enum GetAllSecureIdValuesError {
|
public enum GetAllSecureIdValuesError {
|
||||||
case generic
|
case generic
|
||||||
|
case versionOutdated
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct EncryptedAllSecureIdValues {
|
public struct EncryptedAllSecureIdValues {
|
||||||
@@ -316,8 +328,13 @@ public struct EncryptedAllSecureIdValues {
|
|||||||
|
|
||||||
public func getAllSecureIdValues(network: Network) -> Signal<EncryptedAllSecureIdValues, GetAllSecureIdValuesError> {
|
public func getAllSecureIdValues(network: Network) -> Signal<EncryptedAllSecureIdValues, GetAllSecureIdValuesError> {
|
||||||
return network.request(Api.functions.account.getAllSecureValues())
|
return network.request(Api.functions.account.getAllSecureValues())
|
||||||
|> mapError { _ -> GetAllSecureIdValuesError in
|
|> mapError { error -> GetAllSecureIdValuesError in
|
||||||
return .generic
|
switch error.errorDescription {
|
||||||
|
case "APP_VERSION_OUTDATED":
|
||||||
|
return .versionOutdated
|
||||||
|
default:
|
||||||
|
return .generic
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|> map { result in
|
|> map { result in
|
||||||
return EncryptedAllSecureIdValues(values: result)
|
return EncryptedAllSecureIdValues(values: result)
|
||||||
|
|||||||
Reference in New Issue
Block a user