mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Automatic discovery of the sliding sync proxy. (#535)
* Automatic discovery of the sliding sync proxy. * Handle homeserver detection from a MXID. * Update sliding sync info link, SDK and bump patch. Add a migration on the new version. The change in restoration token format requires the user to sign in again, but this will fail with the existing device ID.
This commit is contained in:
@@ -26,7 +26,9 @@ class AuthenticationServiceProxy: AuthenticationServiceProxyProtocol {
|
||||
|
||||
init(userSessionStore: UserSessionStoreProtocol) {
|
||||
self.userSessionStore = userSessionStore
|
||||
authenticationService = AuthenticationService(basePath: userSessionStore.baseDirectory.path, passphrase: nil)
|
||||
authenticationService = AuthenticationService(basePath: userSessionStore.baseDirectory.path,
|
||||
passphrase: nil,
|
||||
customSlidingSyncProxy: ServiceLocator.shared.settings.slidingSyncProxyURL?.absoluteString)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
@@ -51,6 +53,9 @@ class AuthenticationServiceProxy: AuthenticationServiceProxyProtocol {
|
||||
|
||||
self.homeserver = homeserver
|
||||
return .success(())
|
||||
} catch AuthenticationError.SlidingSyncNotAvailable {
|
||||
MXLog.info("User entered a homeserver that isn't configured for sliding sync.")
|
||||
return .failure(.slidingSyncNotAvailable)
|
||||
} catch {
|
||||
MXLog.error("Failed configuring a server: \(error)")
|
||||
return .failure(.invalidHomeserverAddress)
|
||||
|
||||
@@ -23,6 +23,7 @@ enum AuthenticationServiceError: Error {
|
||||
case invalidServer
|
||||
case invalidCredentials
|
||||
case invalidHomeserverAddress
|
||||
case slidingSyncNotAvailable
|
||||
case accountDeactivated
|
||||
case failedLoggingIn
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ class ClientProxy: ClientProxyProtocol {
|
||||
}
|
||||
|
||||
do {
|
||||
let slidingSyncBuilder = try client.slidingSync().homeserver(url: ServiceLocator.shared.settings.slidingSyncProxyURL.absoluteString)
|
||||
let slidingSyncBuilder = client.slidingSync()
|
||||
|
||||
// Build the visibleRoomsSlidingSyncView here so that it can take advantage of the SS builder cold cache
|
||||
// We will still register the allRoomsSlidingSyncView later, and than will have no cache
|
||||
|
||||
@@ -29,7 +29,8 @@ extension MatrixRustSDK.Session: Codable {
|
||||
userId: try container.decode(String.self, forKey: .userId),
|
||||
deviceId: try container.decode(String.self, forKey: .deviceId),
|
||||
homeserverUrl: try container.decode(String.self, forKey: .homeserverUrl),
|
||||
isSoftLogout: try container.decode(Bool.self, forKey: .isSoftLogout))
|
||||
isSoftLogout: try container.decode(Bool.self, forKey: .isSoftLogout),
|
||||
slidingSyncProxy: try container.decode(String.self, forKey: .slidingSyncProxy))
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@@ -40,9 +41,10 @@ extension MatrixRustSDK.Session: Codable {
|
||||
try container.encode(deviceId, forKey: .deviceId)
|
||||
try container.encode(homeserverUrl, forKey: .homeserverUrl)
|
||||
try container.encode(isSoftLogout, forKey: .isSoftLogout)
|
||||
try container.encode(slidingSyncProxy, forKey: .slidingSyncProxy)
|
||||
}
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case accessToken, refreshToken, userId, deviceId, homeserverUrl, isSoftLogout
|
||||
case accessToken, refreshToken, userId, deviceId, homeserverUrl, isSoftLogout, slidingSyncProxy
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user