Use the ClientFactory pattern everywhere replacing raw ClientBuilders.

# Conflicts:
#	ElementX/Sources/Services/UserSession/UserSessionStore.swift
#	NSE/Sources/NSEUserSession.swift
This commit is contained in:
Doug
2026-08-20 11:50:18 +01:00
committed by Doug
parent 5481f35727
commit 9c65d36101
22 changed files with 571 additions and 377 deletions
@@ -0,0 +1,24 @@
//
// Copyright 2026 Element Creations Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Foundation
import MatrixRustSDK
import MatrixRustSDKMocks
nonisolated extension ClientBuilderSDKMock {
struct Configuration {
var disableWellKnownLookup = false
}
enum MockError: Error { case generic }
convenience init(_ configuration: Configuration) {
self.init()
disableWellKnownLookupDisableWellKnownLookupReturnValue = self
}
}
@@ -14,7 +14,7 @@ nonisolated extension ClientSDKMock {
struct Configuration {
// MARK: Authentication
var serverAddress = "matrix.org"
var serverName = "matrix.org"
var homeserverURL = "https://matrix-client.matrix.org"
var slidingSyncVersion = SlidingSyncVersion.native
var oAuthLoginURL: String? = "https://account.matrix.org/authorize"
@@ -43,7 +43,7 @@ nonisolated extension ClientSDKMock {
homeserverLoginDetailsReturnValue = HomeserverLoginDetailsSDKMock(configuration: configuration)
slidingSyncVersionReturnValue = configuration.slidingSyncVersion
userIdServerNameThrowableError = MockError.generic
serverReturnValue = "https://\(configuration.serverAddress)"
serverReturnValue = "https://\(configuration.serverName)"
homeserverReturnValue = configuration.homeserverURL
urlForOauthOauthConfigurationPromptLoginHintDeviceIdAdditionalScopesReturnValue = OAuthAuthorizationDataSDKMock(configuration: configuration)
loginUsernamePasswordInitialDeviceNameDeviceIdClosure = { [weak self] username, password, _, _ in
@@ -54,7 +54,7 @@ nonisolated extension ClientSDKMock {
if username.hasPrefix("@"), username.contains(":") {
self?.userIdReturnValue = username
} else {
self?.userIdReturnValue = "@\(username):\(configuration.serverAddress)"
self?.userIdReturnValue = "@\(username):\(configuration.serverName)"
}
}