From 9b949ce84ef006d1021809860bd630e4e07f12cb Mon Sep 17 00:00:00 2001 From: Mauro <34335419+Velin92@users.noreply.github.com> Date: Wed, 21 Feb 2024 15:17:23 +0100 Subject: [PATCH] Configure SDK to use the global/OS proxy (#2493) --- ElementX.xcodeproj/project.pbxproj | 34 ++++++----- .../xcshareddata/swiftpm/Package.resolved | 4 +- .../Mocks/Generated/SDKGeneratedMocks.swift | 56 ++++++++++++++++--- ElementX/Sources/Other/Extensions/URL.swift | 13 +++++ .../AuthenticationServiceProxy.swift | 3 +- .../Sources/Services/Room/RoomProxy.swift | 12 ++-- .../Services/Room/RoomProxyProtocol.swift | 1 + .../UserSession/UserSessionStore.swift | 17 ++++-- NSE/Sources/Other/NSEUserSession.swift | 12 +++- project.yml | 2 +- 10 files changed, 117 insertions(+), 37 deletions(-) diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 59162582e..2f67624b2 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 56; + objectVersion = 54; objects = { /* Begin PBXAggregateTarget section */ @@ -1076,7 +1076,7 @@ 033DB41C51865A2E83174E87 /* target.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = target.yml; sourceTree = ""; }; 035177BCD8E8308B098AC3C2 /* WindowManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowManager.swift; sourceTree = ""; }; 0376C429FAB1687C3D905F3E /* MockCoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockCoder.swift; sourceTree = ""; }; - 0392E3FDE372C9B56FEEED8B /* test_voice_message.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_voice_message.m4a; sourceTree = ""; }; + 0392E3FDE372C9B56FEEED8B /* test_voice_message.m4a */ = {isa = PBXFileReference; path = test_voice_message.m4a; sourceTree = ""; }; 03DD998E523D4EC93C7ED703 /* RoomNotificationSettingsScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomNotificationSettingsScreenViewModelProtocol.swift; sourceTree = ""; }; 03FABD73FD8086EFAB699F42 /* MediaUploadPreviewScreenViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaUploadPreviewScreenViewModelTests.swift; sourceTree = ""; }; 044E501B8331B339874D1B96 /* CompoundIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompoundIcon.swift; sourceTree = ""; }; @@ -1137,7 +1137,7 @@ 127A57D053CE8C87B5EFB089 /* Consumable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Consumable.swift; sourceTree = ""; }; 127C8472672A5BA09EF1ACF8 /* CurrentValuePublisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentValuePublisher.swift; sourceTree = ""; }; 12F1E7F9C2BE8BB751037826 /* WaitlistScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaitlistScreenCoordinator.swift; sourceTree = ""; }; - 1304D9191300873EADA52D6E /* IntegrationTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = IntegrationTests.xctestplan; sourceTree = ""; }; + 1304D9191300873EADA52D6E /* IntegrationTests.xctestplan */ = {isa = PBXFileReference; path = IntegrationTests.xctestplan; sourceTree = ""; }; 130ED565A078F7E0B59D9D25 /* UNTextInputNotificationResponse+Creator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UNTextInputNotificationResponse+Creator.swift"; sourceTree = ""; }; 13802897C7AFA360EA74C0B0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = ""; }; 1423AB065857FA546444DB15 /* NotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationManager.swift; sourceTree = ""; }; @@ -1581,7 +1581,7 @@ 8D55702474F279D910D2D162 /* RoomStateEventStringBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomStateEventStringBuilder.swift; sourceTree = ""; }; 8D8169443E5AC5FF71BFB3DB /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = ""; }; 8DC2C9E0E15C79BBDA80F0A2 /* TimelineStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineStyle.swift; sourceTree = ""; }; - 8E088F2A1B9EC529D3221931 /* UITests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = UITests.xctestplan; sourceTree = ""; }; + 8E088F2A1B9EC529D3221931 /* UITests.xctestplan */ = {isa = PBXFileReference; path = UITests.xctestplan; sourceTree = ""; }; 8E1BBA73B611EDEEA6E20E05 /* InvitesScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InvitesScreenModels.swift; sourceTree = ""; }; 8EC57A32ABC80D774CC663DB /* SettingsScreenUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsScreenUITests.swift; sourceTree = ""; }; 8F21ED7205048668BEB44A38 /* AppActivityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppActivityView.swift; sourceTree = ""; }; @@ -1722,7 +1722,7 @@ B50F03079F6B5EF9CA005F14 /* TimelineProxyProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineProxyProtocol.swift; sourceTree = ""; }; B590BD4507D4F0A377FDE01A /* LoadableAvatarImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadableAvatarImage.swift; sourceTree = ""; }; B5B243E7818E5E9F6A4EDC7A /* NoticeRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoticeRoomTimelineView.swift; sourceTree = ""; }; - B61C339A2FDDBD067FF6635C /* ConfettiScene.scn */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = ConfettiScene.scn; sourceTree = ""; }; + B61C339A2FDDBD067FF6635C /* ConfettiScene.scn */ = {isa = PBXFileReference; path = ConfettiScene.scn; sourceTree = ""; }; B6311F21F911E23BE4DF51B4 /* ReadMarkerRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadMarkerRoomTimelineView.swift; sourceTree = ""; }; B63B69F9A2BC74DD40DC75C8 /* AdvancedSettingsScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedSettingsScreenViewModel.swift; sourceTree = ""; }; B697816AF93DA06EC58C5D70 /* WaitlistScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaitlistScreenViewModelProtocol.swift; sourceTree = ""; }; @@ -1831,7 +1831,7 @@ CE47A97726F0675DEE387BF9 /* TypingIndicatorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypingIndicatorView.swift; sourceTree = ""; }; CEE0E6043EFCF6FD2A341861 /* TimelineReplyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineReplyView.swift; sourceTree = ""; }; CEE20623EB4A9B88FB29F2BA /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/SAS.strings; sourceTree = ""; }; - CEE41494C837AA403A06A5D9 /* UnitTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = UnitTests.xctestplan; sourceTree = ""; }; + CEE41494C837AA403A06A5D9 /* UnitTests.xctestplan */ = {isa = PBXFileReference; path = UnitTests.xctestplan; sourceTree = ""; }; CF48AF076424DBC1615C74AD /* AuthenticationServiceProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationServiceProxy.swift; sourceTree = ""; }; D0140615D2232612C813FD6C /* EncryptedHistoryRoomTimelineItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptedHistoryRoomTimelineItem.swift; sourceTree = ""; }; D071F86CD47582B9196C9D16 /* UserDiscoverySection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDiscoverySection.swift; sourceTree = ""; }; @@ -1941,7 +1941,7 @@ ECF79FB25E2D4BD6F50CE7C9 /* RoomMembersListScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMembersListScreenViewModel.swift; sourceTree = ""; }; ED044D00F2176681CC02CD54 /* HomeScreenRoomCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeScreenRoomCell.swift; sourceTree = ""; }; ED1D792EB82506A19A72C8DE /* RoomTimelineItemProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomTimelineItemProtocol.swift; sourceTree = ""; }; - ED482057AE39D5C6D9C5F3D8 /* message.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = message.caf; sourceTree = ""; }; + ED482057AE39D5C6D9C5F3D8 /* message.caf */ = {isa = PBXFileReference; path = message.caf; sourceTree = ""; }; ED983D4DCA5AFA6E1ED96099 /* StateRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StateRoomTimelineView.swift; sourceTree = ""; }; EDAA4472821985BF868CC21C /* ServerSelectionViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerSelectionViewModelTests.swift; sourceTree = ""; }; EE378083653EF0C9B5E9D580 /* EmoteRoomTimelineItemContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmoteRoomTimelineItemContent.swift; sourceTree = ""; }; @@ -1959,7 +1959,7 @@ F174A5627CDB3CAF280D1880 /* EmojiPickerScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPickerScreenModels.swift; sourceTree = ""; }; F17EFA1D3D09FC2F9C5E1CB2 /* MediaProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaProvider.swift; sourceTree = ""; }; F1B8500C152BC59445647DA8 /* UnsupportedRoomTimelineItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnsupportedRoomTimelineItem.swift; sourceTree = ""; }; - F2D513D2477B57F90E98EEC0 /* portrait_test_video.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = portrait_test_video.mp4; sourceTree = ""; }; + F2D513D2477B57F90E98EEC0 /* portrait_test_video.mp4 */ = {isa = PBXFileReference; path = portrait_test_video.mp4; sourceTree = ""; }; F31F59030205A6F65B057E1A /* MatrixEntityRegexTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatrixEntityRegexTests.swift; sourceTree = ""; }; F348B5F2C12F9D4F4B4D3884 /* VideoRoomTimelineItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoRoomTimelineItem.swift; sourceTree = ""; }; F36C0A6D59717193F49EA986 /* UserSessionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserSessionTests.swift; sourceTree = ""; }; @@ -6287,7 +6287,9 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = "$(MARKETING_VERSION)"; - OTHER_SWIFT_FLAGS = "-DIS_NSE"; + OTHER_SWIFT_FLAGS = ( + "-DIS_NSE", + ); PRODUCT_BUNDLE_IDENTIFIER = "${BASE_BUNDLE_IDENTIFIER}.nse"; PRODUCT_DISPLAY_NAME = "$(APP_DISPLAY_NAME)"; PRODUCT_NAME = NSE; @@ -6318,7 +6320,9 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = "$(MARKETING_VERSION)"; - OTHER_SWIFT_FLAGS = "-DIS_MAIN_APP"; + OTHER_SWIFT_FLAGS = ( + "-DIS_MAIN_APP", + ); PILLS_UT_TYPE_IDENTIFIER = "$(BASE_BUNDLE_IDENTIFIER).pills"; PRODUCT_BUNDLE_IDENTIFIER = "$(BASE_BUNDLE_IDENTIFIER)"; PRODUCT_NAME = "$(APP_NAME)"; @@ -6344,7 +6348,9 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = "$(MARKETING_VERSION)"; - OTHER_SWIFT_FLAGS = "-DIS_MAIN_APP"; + OTHER_SWIFT_FLAGS = ( + "-DIS_MAIN_APP", + ); PILLS_UT_TYPE_IDENTIFIER = "$(BASE_BUNDLE_IDENTIFIER).pills"; PRODUCT_BUNDLE_IDENTIFIER = "$(BASE_BUNDLE_IDENTIFIER)"; PRODUCT_NAME = "$(APP_NAME)"; @@ -6587,7 +6593,9 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = "$(MARKETING_VERSION)"; - OTHER_SWIFT_FLAGS = "-DIS_NSE"; + OTHER_SWIFT_FLAGS = ( + "-DIS_NSE", + ); PRODUCT_BUNDLE_IDENTIFIER = "${BASE_BUNDLE_IDENTIFIER}.nse"; PRODUCT_DISPLAY_NAME = "$(APP_DISPLAY_NAME)"; PRODUCT_NAME = NSE; @@ -6769,7 +6777,7 @@ repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift"; requirement = { kind = exactVersion; - version = 1.1.41; + version = 1.1.42; }; }; 821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index d05459c05..e0e130656 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -130,8 +130,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/matrix-org/matrix-rust-components-swift", "state" : { - "revision" : "d773c12e46b01b6512b9b3581268093c8ba4d55d", - "version" : "1.1.41" + "revision" : "62a45668e8e8a70079b8fae0b8031852533900e9", + "version" : "1.1.42" } }, { diff --git a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift index 36e2b9fdc..b786829fa 100644 --- a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift @@ -1,4 +1,4 @@ -// Generated using Sourcery 2.1.3 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable all @@ -371,16 +371,37 @@ class SDKClientMock: SDKClientProtocol { } public var ignoreUserUserIdReceivedUserId: String? public var ignoreUserUserIdReceivedInvocations: [String] = [] - public var ignoreUserUserIdClosure: ((String) throws -> Void)? + public var ignoreUserUserIdClosure: ((String) async throws -> Void)? - public func ignoreUser(userId: String) throws { + public func ignoreUser(userId: String) async throws { if let error = ignoreUserUserIdThrowableError { throw error } ignoreUserUserIdCallsCount += 1 ignoreUserUserIdReceivedUserId = userId ignoreUserUserIdReceivedInvocations.append(userId) - try ignoreUserUserIdClosure?(userId) + try await ignoreUserUserIdClosure?(userId) + } + //MARK: - ignoredUsers + + public var ignoredUsersThrowableError: Error? + public var ignoredUsersCallsCount = 0 + public var ignoredUsersCalled: Bool { + return ignoredUsersCallsCount > 0 + } + public var ignoredUsersReturnValue: [String]! + public var ignoredUsersClosure: (() async throws -> [String])? + + public func ignoredUsers() async throws -> [String] { + if let error = ignoredUsersThrowableError { + throw error + } + ignoredUsersCallsCount += 1 + if let ignoredUsersClosure = ignoredUsersClosure { + return try await ignoredUsersClosure() + } else { + return ignoredUsersReturnValue + } } //MARK: - login @@ -628,6 +649,27 @@ class SDKClientMock: SDKClientProtocol { setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangReceivedInvocations.append((identifiers: identifiers, kind: kind, appDisplayName: appDisplayName, deviceDisplayName: deviceDisplayName, profileTag: profileTag, lang: lang)) try setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangClosure?(identifiers, kind, appDisplayName, deviceDisplayName, profileTag, lang) } + //MARK: - subscribeToIgnoredUsers + + public var subscribeToIgnoredUsersListenerCallsCount = 0 + public var subscribeToIgnoredUsersListenerCalled: Bool { + return subscribeToIgnoredUsersListenerCallsCount > 0 + } + public var subscribeToIgnoredUsersListenerReceivedListener: IgnoredUsersListener? + public var subscribeToIgnoredUsersListenerReceivedInvocations: [IgnoredUsersListener] = [] + public var subscribeToIgnoredUsersListenerReturnValue: TaskHandle! + public var subscribeToIgnoredUsersListenerClosure: ((IgnoredUsersListener) -> TaskHandle)? + + public func subscribeToIgnoredUsers(listener: IgnoredUsersListener) -> TaskHandle { + subscribeToIgnoredUsersListenerCallsCount += 1 + subscribeToIgnoredUsersListenerReceivedListener = listener + subscribeToIgnoredUsersListenerReceivedInvocations.append(listener) + if let subscribeToIgnoredUsersListenerClosure = subscribeToIgnoredUsersListenerClosure { + return subscribeToIgnoredUsersListenerClosure(listener) + } else { + return subscribeToIgnoredUsersListenerReturnValue + } + } //MARK: - syncService public var syncServiceCallsCount = 0 @@ -654,16 +696,16 @@ class SDKClientMock: SDKClientProtocol { } public var unignoreUserUserIdReceivedUserId: String? public var unignoreUserUserIdReceivedInvocations: [String] = [] - public var unignoreUserUserIdClosure: ((String) throws -> Void)? + public var unignoreUserUserIdClosure: ((String) async throws -> Void)? - public func unignoreUser(userId: String) throws { + public func unignoreUser(userId: String) async throws { if let error = unignoreUserUserIdThrowableError { throw error } unignoreUserUserIdCallsCount += 1 unignoreUserUserIdReceivedUserId = userId unignoreUserUserIdReceivedInvocations.append(userId) - try unignoreUserUserIdClosure?(userId) + try await unignoreUserUserIdClosure?(userId) } //MARK: - uploadAvatar diff --git a/ElementX/Sources/Other/Extensions/URL.swift b/ElementX/Sources/Other/Extensions/URL.swift index 4aaab5c35..0776498ff 100644 --- a/ElementX/Sources/Other/Extensions/URL.swift +++ b/ElementX/Sources/Other/Extensions/URL.swift @@ -67,4 +67,17 @@ extension URL: ExpressibleByStringLiteral { return url } + + var globalProxy: String? { + if let proxySettingsUnmanaged = CFNetworkCopySystemProxySettings() { + let proxySettings = proxySettingsUnmanaged.takeRetainedValue() + let proxiesUnmanaged = CFNetworkCopyProxiesForURL(self as CFURL, proxySettings) + if let proxy = (proxiesUnmanaged.takeRetainedValue() as? [[AnyHashable: Any]])?.first, + let hostname = proxy[kCFProxyHostNameKey] as? String, + let port = proxy[kCFProxyPortNumberKey] as? Int { + return "\(hostname):\(port)" + } + } + return nil + } } diff --git a/ElementX/Sources/Services/Authentication/AuthenticationServiceProxy.swift b/ElementX/Sources/Services/Authentication/AuthenticationServiceProxy.swift index 2df743679..1c053b9d6 100644 --- a/ElementX/Sources/Services/Authentication/AuthenticationServiceProxy.swift +++ b/ElementX/Sources/Services/Authentication/AuthenticationServiceProxy.swift @@ -46,11 +46,12 @@ class AuthenticationServiceProxy: AuthenticationServiceProxyProtocol { policyUri: appSettings.privacyURL.absoluteString, contacts: [appSettings.supportEmailAddress], staticRegistrations: appSettings.oidcStaticRegistrations.mapKeys { $0.absoluteString }) - + authenticationService = AuthenticationService(basePath: userSessionStore.baseDirectory.path, passphrase: passphrase, userAgent: UserAgentBuilder.makeASCIIUserAgent(), additionalRootCertificates: [], + proxy: appSettings.websiteURL.globalProxy, oidcConfiguration: oidcConfiguration, customSlidingSyncProxy: appSettings.slidingSyncProxyURL?.absoluteString, sessionDelegate: userSessionStore.clientSessionDelegate, diff --git a/ElementX/Sources/Services/Room/RoomProxy.swift b/ElementX/Sources/Services/Room/RoomProxy.swift index b0947790a..eb26be5bf 100644 --- a/ElementX/Sources/Services/Room/RoomProxy.swift +++ b/ElementX/Sources/Services/Room/RoomProxy.swift @@ -242,13 +242,11 @@ class RoomProxy: RoomProxyProtocol { sendMessageBackgroundTask?.stop() } - return await Task.dispatch(on: userInitiatedDispatchQueue) { - do { - try self.room.ignoreUser(userId: userID) - return .success(()) - } catch { - return .failure(.failedReportingContent) - } + do { + try await room.ignoreUser(userId: userID) + return .success(()) + } catch { + return .failure(.failedIgnoringUser) } } diff --git a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift index 824c9c1ad..901cec59e 100644 --- a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift +++ b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift @@ -21,6 +21,7 @@ import MatrixRustSDK enum RoomProxyError: Error, Equatable { case failedRedactingEvent case failedReportingContent + case failedIgnoringUser case failedRetrievingMember case failedLeavingRoom case failedAcceptingInvite diff --git a/ElementX/Sources/Services/UserSession/UserSessionStore.swift b/ElementX/Sources/Services/UserSession/UserSessionStore.swift index de1d335a7..41867ec1c 100644 --- a/ElementX/Sources/Services/UserSession/UserSessionStore.swift +++ b/ElementX/Sources/Services/UserSession/UserSessionStore.swift @@ -115,19 +115,28 @@ class UserSessionStore: UserSessionStoreProtocol { if credentials.restorationToken.passphrase != nil { MXLog.info("Restoring client with encrypted store.") } - let builder = ClientBuilder() + + let homeserverURL = credentials.restorationToken.session.homeserverUrl + + var builder = ClientBuilder() .basePath(path: baseDirectory.path) .username(username: credentials.userID) - .homeserverUrl(url: credentials.restorationToken.session.homeserverUrl) + .homeserverUrl(url: homeserverURL) .passphrase(passphrase: credentials.restorationToken.passphrase) .userAgent(userAgent: UserAgentBuilder.makeASCIIUserAgent()) .enableCrossProcessRefreshLock(processId: InfoPlistReader.main.bundleIdentifier, sessionDelegate: keychainController) .serverVersions(versions: ["v1.0", "v1.1", "v1.2", "v1.3", "v1.4", "v1.5"]) // FIXME: Quick and dirty fix for stopping version requests on startup https://github.com/matrix-org/matrix-rust-sdk/pull/1376 - + + if let homeserverURL = URL(string: homeserverURL), + let proxy = homeserverURL.globalProxy { + builder = builder.proxy(url: proxy) + } + let completeBuilder = builder + do { let client: Client = try await Task.dispatch(on: .global()) { - let client = try builder.build() + let client = try completeBuilder.build() try client.restoreSession(session: credentials.restorationToken.session) return client } diff --git a/NSE/Sources/Other/NSEUserSession.swift b/NSE/Sources/Other/NSEUserSession.swift index ea42b928e..8dc0dec45 100644 --- a/NSE/Sources/Other/NSEUserSession.swift +++ b/NSE/Sources/Other/NSEUserSession.swift @@ -31,15 +31,23 @@ final class NSEUserSession { if credentials.restorationToken.passphrase != nil { MXLog.info("Restoring client with encrypted store.") } - baseClient = try ClientBuilder() + + let homeserverURL = credentials.restorationToken.session.homeserverUrl + var clientBuilder = ClientBuilder() .basePath(path: URL.sessionsBaseDirectory.path) .username(username: credentials.userID) + .homeserverUrl(url: homeserverURL) .passphrase(passphrase: credentials.restorationToken.passphrase) .userAgent(userAgent: UserAgentBuilder.makeASCIIUserAgent()) .enableCrossProcessRefreshLock(processId: InfoPlistReader.main.bundleIdentifier, sessionDelegate: clientSessionDelegate) - .build() + if let homeserverURL = URL(string: homeserverURL), + let proxy = homeserverURL.globalProxy { + clientBuilder = clientBuilder.proxy(url: proxy) + } + + baseClient = try clientBuilder.build() delegateHandle = baseClient.setDelegate(delegate: ClientDelegateWrapper()) try baseClient.restoreSession(session: credentials.restorationToken.session) diff --git a/project.yml b/project.yml index bfe18e4fb..652d89b54 100644 --- a/project.yml +++ b/project.yml @@ -47,7 +47,7 @@ packages: # Element/Matrix dependencies MatrixRustSDK: url: https://github.com/matrix-org/matrix-rust-components-swift - exactVersion: 1.1.41 + exactVersion: 1.1.42 # path: ../matrix-rust-sdk Compound: url: https://github.com/element-hq/compound-ios