mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-18 23:48:29 +02:00
Refactor cross signing banner.
This commit is contained in:
@@ -16,17 +16,15 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
final class KeyVerificationService: NSObject {
|
||||
final class KeyVerificationService {
|
||||
|
||||
private let cameraAccessManager: CameraAccessManager
|
||||
|
||||
private var authenticatedSessionFactory: AuthenticatedSessionViewControllerFactory?
|
||||
private var supportSetupKeyVerificationByUser: [String: Bool] = [:] // Cached server response
|
||||
|
||||
override init() {
|
||||
init() {
|
||||
self.cameraAccessManager = CameraAccessManager()
|
||||
super.init()
|
||||
}
|
||||
|
||||
func supportedKeyVerificationMethods() -> [String] {
|
||||
@@ -42,43 +40,4 @@ final class KeyVerificationService: NSObject {
|
||||
|
||||
return supportedMethods
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
func canSetupKeyVerification(for session: MXSession, success: @escaping ((Bool) -> Void), failure: @escaping ((Error) -> Void)) -> MXHTTPOperation? {
|
||||
|
||||
guard let crossSigning = session.crypto?.crossSigning, crossSigning.state == .notBootstrapped else {
|
||||
// Cross-signing already setup
|
||||
success(false)
|
||||
return nil
|
||||
}
|
||||
|
||||
let userId: String = session.myUserId
|
||||
|
||||
if let supportSetupKeyVerification = self.supportSetupKeyVerificationByUser[userId] {
|
||||
// Return cached response
|
||||
success(supportSetupKeyVerification)
|
||||
return nil
|
||||
}
|
||||
|
||||
let authenticatedSessionFactory = AuthenticatedSessionViewControllerFactory(session: session)
|
||||
|
||||
self.authenticatedSessionFactory = authenticatedSessionFactory
|
||||
|
||||
let path = "\(kMXAPIPrefixPathUnstable)/keys/device_signing/upload"
|
||||
|
||||
return authenticatedSessionFactory.hasSupport(forPath: path, httpMethod: "POST", success: { [weak self] succeeded in
|
||||
guard let self = self else {
|
||||
return
|
||||
}
|
||||
self.authenticatedSessionFactory = nil
|
||||
self.supportSetupKeyVerificationByUser[userId] = succeeded
|
||||
success(succeeded)
|
||||
}, failure: { [weak self] error in
|
||||
guard let self = self else {
|
||||
return
|
||||
}
|
||||
self.authenticatedSessionFactory = nil
|
||||
failure(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user