diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 8a7c9af85..5625c0930 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -164,7 +164,6 @@ 7BFA8AE32831D0D4001876F3 /* ContextMenuVC+EmojiReactsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BFA8AE22831D0D4001876F3 /* ContextMenuVC+EmojiReactsView.swift */; }; 7BFD1A8A2745C4F000FB91B9 /* Permissions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BFD1A892745C4F000FB91B9 /* Permissions.swift */; }; 7BFD1A972747689000FB91B9 /* Session-Turn-Server in Resources */ = {isa = PBXBuildFile; fileRef = 7BFD1A962747689000FB91B9 /* Session-Turn-Server */; }; - 88C614F4223F9BE0CB94E4E5 /* Pods_GlobalDependencies_FrameworkAndExtensionDependencies_ExtendedDependencies_SessionUtilitiesKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 35C5EF2AACD4A39D6E0E2C49 /* Pods_GlobalDependencies_FrameworkAndExtensionDependencies_ExtendedDependencies_SessionUtilitiesKit.framework */; }; 942256802C23F8BB00C0FDBF /* StartConversationScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9422567D2C23F8BB00C0FDBF /* StartConversationScreen.swift */; }; 942256812C23F8BB00C0FDBF /* NewMessageScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9422567E2C23F8BB00C0FDBF /* NewMessageScreen.swift */; }; 942256822C23F8BB00C0FDBF /* InviteAFriendScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9422567F2C23F8BB00C0FDBF /* InviteAFriendScreen.swift */; }; @@ -227,7 +226,6 @@ B8856D72256F1421001CE70E /* OWSWindowManager.h in Headers */ = {isa = PBXBuildFile; fileRef = C38EF2FB255B6DBD007E1867 /* OWSWindowManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; B8856DE6256F15F2001CE70E /* String+SSK.swift in Sources */ = {isa = PBXBuildFile; fileRef = C33FDB3F255A580C00E217F9 /* String+SSK.swift */; }; B8856E09256F1676001CE70E /* UIDevice+featureSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38EF237255B6D65007E1867 /* UIDevice+featureSupport.swift */; }; - B886B4A72398B23E00211ABE /* QRCodeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B886B4A62398B23E00211ABE /* QRCodeVC.swift */; }; B886B4A92398BA1500211ABE /* QRCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = B886B4A82398BA1500211ABE /* QRCode.swift */; }; B88FA7F2260C3EB10049422F /* OpenGroupSuggestionGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = B88FA7F1260C3EB10049422F /* OpenGroupSuggestionGrid.swift */; }; B88FA7FB26114EA70049422F /* Hex.swift in Sources */ = {isa = PBXBuildFile; fileRef = B88FA7FA26114EA70049422F /* Hex.swift */; }; @@ -494,7 +492,6 @@ FD1D732E2A86114600E3F410 /* _015_BlockCommunityMessageRequests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD1D732D2A86114600E3F410 /* _015_BlockCommunityMessageRequests.swift */; }; FD1F9C9F2A862BE60050F671 /* MigrationRequirement.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD1F9C9E2A862BE60050F671 /* MigrationRequirement.swift */; }; FD22724B2C326E75004D8A6C /* CustomArgSummaryDescribable+SMK.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD22724A2C326E75004D8A6C /* CustomArgSummaryDescribable+SMK.swift */; }; - FD22724E2C327BA5004D8A6C /* SSKMockedExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD22724D2C327BA5004D8A6C /* SSKMockedExtensions.swift */; }; FD22724F2C327BCA004D8A6C /* SSKMockedExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD22724D2C327BA5004D8A6C /* SSKMockedExtensions.swift */; }; FD22866F2C38D42300BC06F7 /* DifferenceKit in Frameworks */ = {isa = PBXBuildFile; productRef = FD22866E2C38D42300BC06F7 /* DifferenceKit */; }; FD2286712C38D43000BC06F7 /* DifferenceKit in Frameworks */ = {isa = PBXBuildFile; productRef = FD2286702C38D43000BC06F7 /* DifferenceKit */; }; @@ -554,6 +551,8 @@ FD2B4AFD294688D000AB4848 /* LibSession+Contacts.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD2B4AFC294688D000AB4848 /* LibSession+Contacts.swift */; }; FD2B4AFF2946C93200AB4848 /* ConfigurationSyncJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD2B4AFE2946C93200AB4848 /* ConfigurationSyncJob.swift */; }; FD2B4B042949887A00AB4848 /* QueryInterfaceRequest+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD2B4B032949887A00AB4848 /* QueryInterfaceRequest+Utilities.swift */; }; + FD2DD58E2C6DBEBF0073D9BE /* SSKMockedExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD22724D2C327BA5004D8A6C /* SSKMockedExtensions.swift */; }; + FD2DD5902C6DD13C0073D9BE /* DifferenceKit in Frameworks */ = {isa = PBXBuildFile; productRef = FD2DD58F2C6DD13C0073D9BE /* DifferenceKit */; }; FD3003662A25D5B300B5A5FB /* ConfigMessageReceiveJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD3003652A25D5B300B5A5FB /* ConfigMessageReceiveJob.swift */; }; FD368A6829DE8F9C000DBF1E /* _012_AddFTSIfNeeded.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD368A6729DE8F9B000DBF1E /* _012_AddFTSIfNeeded.swift */; }; FD368A6A29DE9E30000DBF1E /* UIContextualAction+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD368A6929DE9E30000DBF1E /* UIContextualAction+Utilities.swift */; }; @@ -674,8 +673,6 @@ FD6A39722C2E3F5800762359 /* GRDBExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD6A39702C2E3F5800762359 /* GRDBExtensions.swift */; }; FD6A39732C2E3F5800762359 /* GRDBExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD6A39702C2E3F5800762359 /* GRDBExtensions.swift */; }; FD6A39742C2E3F5800762359 /* GRDBExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD6A39702C2E3F5800762359 /* GRDBExtensions.swift */; }; - FD6A39772C2E885600762359 /* SSKMockedExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD6A39762C2E885600762359 /* SSKMockedExtensions.swift */; }; - FD6A397A2C2E88EB00762359 /* SSKMockedExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD6A39762C2E885600762359 /* SSKMockedExtensions.swift */; }; FD6A7A692818BE7300035AC1 /* RetrieveDefaultOpenGroupRoomsJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD6A7A682818BE7300035AC1 /* RetrieveDefaultOpenGroupRoomsJob.swift */; }; FD6A7A6B2818C17C00035AC1 /* UpdateProfilePictureJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD6A7A6A2818C17C00035AC1 /* UpdateProfilePictureJob.swift */; }; FD6A7A6D2818C61500035AC1 /* _002_SetupStandardJobs.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD6A7A6C2818C61500035AC1 /* _002_SetupStandardJobs.swift */; }; @@ -897,7 +894,6 @@ FDE6E99829F8E63A00F93C5D /* Accessibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDE6E99729F8E63A00F93C5D /* Accessibility.swift */; }; FDE77F6B280FEB28002CFC5D /* ControlMessageProcessRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDE77F6A280FEB28002CFC5D /* ControlMessageProcessRecord.swift */; }; FDED2E3C282E1B5D00B2CD2A /* UICollectionView+ReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDED2E3B282E1B5D00B2CD2A /* UICollectionView+ReusableView.swift */; }; - FDEF57712C44D2D300131302 /* GeoLite2-Country-Blocks-IPv4 in Resources */ = {isa = PBXBuildFile; fileRef = FDEF57702C44D2D300131302 /* GeoLite2-Country-Blocks-IPv4 */; }; FDEF57212C3CF03A00131302 /* WebRTCSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8DE1FB326C22F2F0079C9CE /* WebRTCSession.swift */; }; FDEF57222C3CF03D00131302 /* WebRTCSession+UI.swift in Sources */ = {isa = PBXBuildFile; fileRef = B806ECA026C4A7E4008BDA44 /* WebRTCSession+UI.swift */; }; FDEF57232C3CF04300131302 /* WebRTCSession+MessageHandling.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8B558FE26C4E05E00693325 /* WebRTCSession+MessageHandling.swift */; }; @@ -905,6 +901,7 @@ FDEF57252C3CF04C00131302 /* WebRTCSession+DataChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BCD116B27016062006330F1 /* WebRTCSession+DataChannel.swift */; }; FDEF57262C3CF05F00131302 /* TurnServerInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BFD1A8B2747150E00FB91B9 /* TurnServerInfo.swift */; }; FDEF572A2C3CF50B00131302 /* WebRTC in Frameworks */ = {isa = PBXBuildFile; productRef = FDEF57292C3CF50B00131302 /* WebRTC */; }; + FDEF57712C44D2D300131302 /* GeoLite2-Country-Blocks-IPv4 in Resources */ = {isa = PBXBuildFile; fileRef = FDEF57702C44D2D300131302 /* GeoLite2-Country-Blocks-IPv4 */; }; FDF0B73C27FFD3D6004C14C5 /* LinkPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDF0B73B27FFD3D6004C14C5 /* LinkPreview.swift */; }; FDF0B7422804EA4F004C14C5 /* _002_SetupStandardJobs.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDF0B7412804EA4F004C14C5 /* _002_SetupStandardJobs.swift */; }; FDF0B7472804F0CE004C14C5 /* DisappearingMessagesJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDF0B7462804F0CE004C14C5 /* DisappearingMessagesJob.swift */; }; @@ -1355,11 +1352,6 @@ 7BFD1A892745C4F000FB91B9 /* Permissions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Permissions.swift; sourceTree = ""; }; 7BFD1A8B2747150E00FB91B9 /* TurnServerInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnServerInfo.swift; sourceTree = ""; }; 7BFD1A962747689000FB91B9 /* Session-Turn-Server */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Session-Turn-Server"; sourceTree = ""; }; - 7C0E07EB26851D7BB4CF060E /* Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SessionUtilitiesKit.app store release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SessionUtilitiesKit.app store release.xcconfig"; path = "Target Support Files/Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SessionUtilitiesKit/Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SessionUtilitiesKit.app store release.xcconfig"; sourceTree = ""; }; - 7FE80FEC012334C282A6C8CB /* Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SessionUtilitiesKit-SessionUtilitiesKitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SessionUtilitiesKit-SessionUtilitiesKitTests.debug.xcconfig"; path = "Target Support Files/Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SessionUtilitiesKit-SessionUtilitiesKitTests/Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SessionUtilitiesKit-SessionUtilitiesKitTests.debug.xcconfig"; sourceTree = ""; }; - 81B86106CE32C944E6A3A8F2 /* Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SessionShareExtension.app_store_release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SessionShareExtension.app_store_release.xcconfig"; path = "Target Support Files/Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SessionShareExtension/Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SessionShareExtension.app_store_release.xcconfig"; sourceTree = ""; }; - 89EE44A6174C653D2F4DB573 /* Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SignalUtilitiesKit.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SignalUtilitiesKit.debug.xcconfig"; path = "Target Support Files/Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SignalUtilitiesKit/Pods-GlobalDependencies-FrameworkAndExtensionDependencies-ExtendedDependencies-SignalUtilitiesKit.debug.xcconfig"; sourceTree = ""; }; - 91271A534D1D4AB949B1319E /* Pods-GlobalDependencies-FrameworkAndExtensionDependencies-SessionNotificationServiceExtension.app store release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GlobalDependencies-FrameworkAndExtensionDependencies-SessionNotificationServiceExtension.app store release.xcconfig"; path = "Target Support Files/Pods-GlobalDependencies-FrameworkAndExtensionDependencies-SessionNotificationServiceExtension/Pods-GlobalDependencies-FrameworkAndExtensionDependencies-SessionNotificationServiceExtension.app store release.xcconfig"; sourceTree = ""; }; 9422567D2C23F8BB00C0FDBF /* StartConversationScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StartConversationScreen.swift; sourceTree = ""; }; 9422567E2C23F8BB00C0FDBF /* NewMessageScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewMessageScreen.swift; sourceTree = ""; }; 9422567F2C23F8BB00C0FDBF /* InviteAFriendScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InviteAFriendScreen.swift; sourceTree = ""; }; @@ -2295,6 +2287,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + FD2DD5902C6DD13C0073D9BE /* DifferenceKit in Frameworks */, FD6A39322C2AD33E00762359 /* Quick in Frameworks */, FD6A393B2C2AD3A300762359 /* Nimble in Frameworks */, ); @@ -3546,6 +3539,7 @@ FDE7214E287E50D50093DF33 /* Scripts */, D221A08C169C9E5E00537ABF /* Frameworks */, D221A08A169C9E5E00537ABF /* Products */, + FD2DD58D2C6DB8A70073D9BE /* Recovered References */, ); sourceTree = ""; }; @@ -3844,6 +3838,14 @@ path = Database; sourceTree = ""; }; + FD2DD58D2C6DB8A70073D9BE /* Recovered References */ = { + isa = PBXGroup; + children = ( + FD6A39762C2E885600762359 /* SSKMockedExtensions.swift */, + ); + name = "Recovered References"; + sourceTree = ""; + }; FD37E9C428A1C701003AE748 /* Themes */ = { isa = PBXGroup; children = ( @@ -3947,14 +3949,6 @@ path = Crypto; sourceTree = ""; }; - FD6A39752C2E884500762359 /* _TestUtilities */ = { - isa = PBXGroup; - children = ( - FD6A39762C2E885600762359 /* SSKMockedExtensions.swift */, - ); - path = _TestUtilities; - sourceTree = ""; - }; FD7115F528C8150600B47552 /* Combine */ = { isa = PBXGroup; children = ( @@ -4420,6 +4414,19 @@ path = Scripts; sourceTree = ""; }; + FDEF57202C3CF02000131302 /* WebRTC */ = { + isa = PBXGroup; + children = ( + 7BFD1A8B2747150E00FB91B9 /* TurnServerInfo.swift */, + B8DE1FB326C22F2F0079C9CE /* WebRTCSession.swift */, + B806ECA026C4A7E4008BDA44 /* WebRTCSession+UI.swift */, + B8B558FE26C4E05E00693325 /* WebRTCSession+MessageHandling.swift */, + B8BF43B926CC95FB007828D1 /* WebRTC+Utilities.swift */, + 7BCD116B27016062006330F1 /* WebRTCSession+DataChannel.swift */, + ); + path = WebRTC; + sourceTree = ""; + }; FDEF576F2C44C1DF00131302 /* SourceData */ = { isa = PBXGroup; children = ( @@ -4437,19 +4444,6 @@ path = Countries/SourceData; sourceTree = ""; }; - FDEF57202C3CF02000131302 /* WebRTC */ = { - isa = PBXGroup; - children = ( - 7BFD1A8B2747150E00FB91B9 /* TurnServerInfo.swift */, - B8DE1FB326C22F2F0079C9CE /* WebRTCSession.swift */, - B806ECA026C4A7E4008BDA44 /* WebRTCSession+UI.swift */, - B8B558FE26C4E05E00693325 /* WebRTCSession+MessageHandling.swift */, - B8BF43B926CC95FB007828D1 /* WebRTC+Utilities.swift */, - 7BCD116B27016062006330F1 /* WebRTCSession+DataChannel.swift */, - ); - path = WebRTC; - sourceTree = ""; - }; FDF0B7452804F0A8004C14C5 /* Types */ = { isa = PBXGroup; children = ( @@ -4844,6 +4838,7 @@ packageProductDependencies = ( FD6A39312C2AD33E00762359 /* Quick */, FD6A393A2C2AD3A300762359 /* Nimble */, + FD2DD58F2C6DD13C0073D9BE /* DifferenceKit */, ); productName = SessionTests; productReference = FD71160928D00BAE00B47552 /* SessionTests.xctest */; @@ -6324,10 +6319,9 @@ FD7C37BE2BBB8BBD009DEEA7 /* SnodeRequestSpec.swift in Sources */, FD7C37C02BBB8BE1009DEEA7 /* Mocked.swift in Sources */, FD7C37BF2BBB8BDF009DEEA7 /* Mock.swift in Sources */, - FD6A39772C2E885600762359 /* SSKMockedExtensions.swift in Sources */, + FD2DD58E2C6DBEBF0073D9BE /* SSKMockedExtensions.swift in Sources */, FD7C37C22BBB8BED009DEEA7 /* MockCaches.swift in Sources */, FD7C37C62BBB8C08009DEEA7 /* TestConstants.swift in Sources */, - FD22724E2C327BA5004D8A6C /* SSKMockedExtensions.swift in Sources */, FD7C37C82BBB8C11009DEEA7 /* NimbleExtensions.swift in Sources */, FD7C37C52BBB8C01009DEEA7 /* MockJobRunner.swift in Sources */, FD7C37CB2BBB8D36009DEEA7 /* MockUserDefaults.swift in Sources */, @@ -8709,6 +8703,11 @@ package = FD6A38ED2C2A641200762359 /* XCRemoteSwiftPackageReference "DifferenceKit" */; productName = DifferenceKit; }; + FD2DD58F2C6DD13C0073D9BE /* DifferenceKit */ = { + isa = XCSwiftPackageProductDependency; + package = FD6A38ED2C2A641200762359 /* XCRemoteSwiftPackageReference "DifferenceKit" */; + productName = DifferenceKit; + }; FD6A38E52C2A4D8E00762359 /* GRDB */ = { isa = XCSwiftPackageProductDependency; package = FD6A38E42C2A4D8E00762359 /* XCRemoteSwiftPackageReference "session-grdb-swift" */; diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index c3f480b5c..50768ae75 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -546,7 +546,8 @@ final class ConversationVC: BaseVC, LibSessionRespondingViewController, Conversa !LibSession.conversationInConfig( threadId: threadId, threadVariant: viewModel.threadData.threadVariant, - visibleOnly: false + visibleOnly: false, + using: viewModel.dependencies ) { Storage.shared.writeAsync { db in diff --git a/Session/Home/New Conversation/NewMessageScreen.swift b/Session/Home/New Conversation/NewMessageScreen.swift index 9b569606a..a7adc15b3 100644 --- a/Session/Home/New Conversation/NewMessageScreen.swift +++ b/Session/Home/New Conversation/NewMessageScreen.swift @@ -68,7 +68,7 @@ struct NewMessageScreen: View { } func continueWithAccountIdOrONS() { - let maybeSessionId: SessionId? = SessionId(from: accountIdOrONS) + let maybeSessionId: SessionId? = try? SessionId(from: accountIdOrONS) if KeyPair.isValidHexEncodedPublicKey(candidate: accountIdOrONS) { switch maybeSessionId?.prefix { diff --git a/Session/Onboarding/DisplayNameScreen.swift b/Session/Onboarding/DisplayNameScreen.swift index 528da1c72..92dd172bb 100644 --- a/Session/Onboarding/DisplayNameScreen.swift +++ b/Session/Onboarding/DisplayNameScreen.swift @@ -125,7 +125,7 @@ struct DisplayNameScreen: View { guard self.flow == .register else { self.flow.completeRegistration() - let homeVC: HomeVC = HomeVC(flow: self.flow) + let homeVC: HomeVC = HomeVC(flow: self.flow, using: dependencies) self.host.controller?.navigationController?.setViewControllers([ homeVC ], animated: true) return diff --git a/Session/Onboarding/LandingScreen.swift b/Session/Onboarding/LandingScreen.swift index 90e45c375..60cd47f61 100644 --- a/Session/Onboarding/LandingScreen.swift +++ b/Session/Onboarding/LandingScreen.swift @@ -1,7 +1,6 @@ // Copyright © 2023 Rangeproof Pty Ltd. All rights reserved. import SwiftUI -import Sodium import SessionUIKit import SignalUtilitiesKit import SessionUtilitiesKit diff --git a/Session/Onboarding/LoadingScreen.swift b/Session/Onboarding/LoadingScreen.swift index af3560ef3..c4e922dab 100644 --- a/Session/Onboarding/LoadingScreen.swift +++ b/Session/Onboarding/LoadingScreen.swift @@ -111,10 +111,10 @@ struct LoadingScreen: View { withAnimation(.linear(duration: 0.3)) { self.percentage = 1 } - DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [dependencies] in self.flow.completeRegistration() - let homeVC: HomeVC = HomeVC(flow: self.flow) + let homeVC: HomeVC = HomeVC(flow: self.flow, using: dependencies) self.host.controller?.navigationController?.setViewControllers([ homeVC ], animated: true) } diff --git a/Session/Onboarding/PNModeScreen.swift b/Session/Onboarding/PNModeScreen.swift index 1e14a38e6..de84699ec 100644 --- a/Session/Onboarding/PNModeScreen.swift +++ b/Session/Onboarding/PNModeScreen.swift @@ -160,7 +160,7 @@ struct PNModeScreen: View { private func finishRegister() { self.flow.completeRegistration() - let homeVC: HomeVC = HomeVC(flow: self.flow) + let homeVC: HomeVC = HomeVC(flow: self.flow, using: dependencies) self.host.controller?.navigationController?.setViewControllers([ homeVC ], animated: true) return } diff --git a/Session/Shared/SessionHostingViewController.swift b/Session/Shared/SessionHostingViewController.swift index 4948a3015..dc0595deb 100644 --- a/Session/Shared/SessionHostingViewController.swift +++ b/Session/Shared/SessionHostingViewController.swift @@ -217,7 +217,7 @@ public class SessionHostingViewController: UIHostingController Bool { - return LibSession + return dependencies.caches[.libSession] .config(for: .convoInfoVolatile, publicKey: userPublicKey) .wrappedValue .map { conf in diff --git a/SessionMessagingKit/LibSession/Config Handling/LibSession+Shared.swift b/SessionMessagingKit/LibSession/Config Handling/LibSession+Shared.swift index b34d621af..5d06cc6ea 100644 --- a/SessionMessagingKit/LibSession/Config Handling/LibSession+Shared.swift +++ b/SessionMessagingKit/LibSession/Config Handling/LibSession+Shared.swift @@ -217,13 +217,17 @@ internal extension LibSession { return updated } - static func hasSetting(_ db: Database, forKey key: String) throws -> Bool { + static func hasSetting( + _ db: Database, + forKey key: String, + using dependencies: Dependencies + ) throws -> Bool { let userPublicKey: String = getUserHexEncodedPublicKey(db) // Currently the only synced setting is 'checkForCommunityMessageRequests' switch key { case Setting.BoolKey.checkForCommunityMessageRequests.rawValue: - return try LibSession + return try dependencies.caches[.libSession] .config(for: .userProfile, publicKey: userPublicKey) .wrappedValue .map { conf -> Bool in (try LibSession.rawBlindedMessageRequestValue(in: conf) >= 0) } @@ -389,7 +393,8 @@ public extension LibSession { _ db: Database? = nil, threadId: String, threadVariant: SessionThread.Variant, - visibleOnly: Bool + visibleOnly: Bool, + using dependencies: Dependencies ) -> Bool { // Currently blinded conversations cannot be contained in the config, so there is no point checking (it'll always be // false) @@ -408,7 +413,7 @@ public extension LibSession { } }() - return LibSession + return dependencies.caches[.libSession] .config(for: configVariant, publicKey: userPublicKey) .wrappedValue .map { conf in diff --git a/SessionMessagingKit/LibSession/LibSession+SessionMessagingKit.swift b/SessionMessagingKit/LibSession/LibSession+SessionMessagingKit.swift index 22c45b83d..f246300b5 100644 --- a/SessionMessagingKit/LibSession/LibSession+SessionMessagingKit.swift +++ b/SessionMessagingKit/LibSession/LibSession+SessionMessagingKit.swift @@ -49,19 +49,8 @@ public extension LibSession { } } - // MARK: - Configs - - // FIXME: This is a temporary work-around for fixing the database unit tests (it's done properly in the Groups Rebuild branch but would require too many changes to pull across properly) - static func config(for variant: ConfigDump.Variant, publicKey: String) -> Atomic?> { - return LibSession.dependencies.wrappedValue.caches[.libSession] - .config(for: variant, publicKey: publicKey) - } - // MARK: - Variables - // FIXME: This is a temporary work-around for fixing the database unit tests (it's done properly in the Groups Rebuild branch but would require too many changes to pull across properly) - private static var dependencies: Atomic = Atomic(Dependencies()) - internal static func syncDedupeId(_ publicKey: String) -> String { return "EnqueueConfigurationSyncJob-\(publicKey)" // stringlint:disable } @@ -80,15 +69,6 @@ public extension LibSession { ed25519SecretKey: [UInt8]?, using dependencies: Dependencies ) { - // FIXME: Replace this with the proper dependency injection (added in Groups Rebuild) - let dependencies: Dependencies = { - guard let dependencies: Dependencies = dependencies else { return LibSession.dependencies.wrappedValue } - - // Store the provided dependencies so we are using the correct cache when running - LibSession.dependencies.mutate { $0 = dependencies } - return dependencies - }() - // Ensure we have the ed25519 key and that we haven't already loaded the state before // we continue guard @@ -104,9 +84,6 @@ public extension LibSession { return } - // FIXME: This is a temporary work-around for fixing the database unit tests (it's done properly in the Groups Rebuild branch but would require too many changes to pull across properly) - LibSession.dependencies = Atomic(dependencies) - // Retrieve the existing dumps from the database let existingDumps: Set = ((try? ConfigDump.fetchSet(db)) ?? []) let existingDumpVariants: Set = existingDumps @@ -228,7 +205,8 @@ public extension LibSession { static func pendingChanges( _ db: Database, - publicKey: String + publicKey: String, + using dependencies: Dependencies ) throws -> PendingChanges { guard Identity.userExists(db) else { throw LibSessionError.userDoesNotExist } @@ -251,70 +229,70 @@ public extension LibSession { /// config while we are reading (which could result in crashes) return try existingDumpVariants .reduce(into: PendingChanges()) { result, variant in - try LibSession - .config(for: variant, publicKey: publicKey) - .mutate { conf in - guard conf != nil else { return } - - // Check if the config needs to be pushed - guard config_needs_push(conf) else { - // If not then try retrieve any obsolete hashes to be removed - guard let cObsoletePtr: UnsafeMutablePointer = config_old_hashes(conf) else { - return - } - - let obsoleteHashes: [String] = [String]( - pointer: cObsoletePtr.pointee.value, - count: cObsoletePtr.pointee.len, - defaultValue: [] - ) - - // If there are no obsolete hashes then no need to return anything - guard !obsoleteHashes.isEmpty else { return } - - result.append(hashes: obsoleteHashes) - return - } - - guard let cPushData: UnsafeMutablePointer = config_push(conf) else { - let configCountInfo: String = { - switch variant { - case .userProfile: return "1 profile" // stringlint:disable - case .contacts: return "\(contacts_size(conf)) contacts" // stringlint:disable - case .userGroups: return "\(user_groups_size(conf)) group conversations" // stringlint:disable - case .convoInfoVolatile: return "\(convo_info_volatile_size(conf)) volatile conversations" // stringlint:disable - case .invalid: return "Invalid" // stringlint:disable - } - }() - - throw LibSessionError( - conf, - fallbackError: .unableToGeneratePushData, - logMessage: "[LibSession] Failed to generate push data for \(variant) config data, size: \(configCountInfo), error" - ) - } + guard + let conf = dependencies.caches[.libSession] + .config(for: variant, publicKey: publicKey) + .wrappedValue + else { return } - let pushData: Data = Data( - bytes: cPushData.pointee.config, - count: cPushData.pointee.config_len - ) - let obsoleteHashes: [String] = [String]( - pointer: cPushData.pointee.obsolete, - count: cPushData.pointee.obsolete_len, - defaultValue: [] - ) - let seqNo: Int64 = cPushData.pointee.seqno - cPushData.deallocate() - - result.append( - data: PendingChanges.PushData( - data: pushData, - seqNo: seqNo, - variant: variant - ), - hashes: obsoleteHashes - ) + // Check if the config needs to be pushed + guard config_needs_push(conf) else { + // If not then try retrieve any obsolete hashes to be removed + guard let cObsoletePtr: UnsafeMutablePointer = config_old_hashes(conf) else { + return } + + let obsoleteHashes: [String] = [String]( + pointer: cObsoletePtr.pointee.value, + count: cObsoletePtr.pointee.len, + defaultValue: [] + ) + + // If there are no obsolete hashes then no need to return anything + guard !obsoleteHashes.isEmpty else { return } + + result.append(hashes: obsoleteHashes) + return + } + + guard let cPushData: UnsafeMutablePointer = config_push(conf) else { + let configCountInfo: String = { + switch variant { + case .userProfile: return "1 profile" // stringlint:disable + case .contacts: return "\(contacts_size(conf)) contacts" // stringlint:disable + case .userGroups: return "\(user_groups_size(conf)) group conversations" // stringlint:disable + case .convoInfoVolatile: return "\(convo_info_volatile_size(conf)) volatile conversations" // stringlint:disable + case .invalid: return "Invalid" // stringlint:disable + } + }() + + throw LibSessionError( + conf, + fallbackError: .unableToGeneratePushData, + logMessage: "[LibSession] Failed to generate push data for \(variant) config data, size: \(configCountInfo), error" + ) + } + + let pushData: Data = Data( + bytes: cPushData.pointee.config, + count: cPushData.pointee.config_len + ) + let obsoleteHashes: [String] = [String]( + pointer: cPushData.pointee.obsolete, + count: cPushData.pointee.obsolete_len, + defaultValue: [] + ) + let seqNo: Int64 = cPushData.pointee.seqno + cPushData.deallocate() + + result.append( + data: PendingChanges.PushData( + data: pushData, + seqNo: seqNo, + variant: variant + ), + hashes: obsoleteHashes + ) } } @@ -323,9 +301,10 @@ public extension LibSession { serverHash: String, sentTimestamp: Int64, variant: ConfigDump.Variant, - publicKey: String + publicKey: String, + using dependencies: Dependencies ) -> ConfigDump? { - return LibSession + return dependencies.caches[.libSession] .config(for: variant, publicKey: publicKey) .mutate { conf in guard @@ -348,7 +327,10 @@ public extension LibSession { } } - static func configHashes(for publicKey: String) -> [String] { + static func configHashes( + for publicKey: String, + using dependencies: Dependencies + ) -> [String] { return Storage.shared .read { db -> Set in guard Identity.userExists(db) else { return [] } @@ -363,7 +345,7 @@ public extension LibSession { .map { variant -> [String] in /// Extract all existing hashes for any dumps associated with the given `publicKey` guard - let conf = LibSession + let conf = dependencies.caches[.libSession] .config(for: variant, publicKey: publicKey) .wrappedValue, let hashList: UnsafeMutablePointer = config_current_hashes(conf) @@ -386,7 +368,8 @@ public extension LibSession { static func handleConfigMessages( _ db: Database, messages: [ConfigMessageReceiveJob.Details.MessageInfo], - publicKey: String + publicKey: String, + using dependencies: Dependencies ) throws { guard !messages.isEmpty else { return } guard !publicKey.isEmpty else { throw MessageReceiverError.noThread } @@ -397,7 +380,7 @@ public extension LibSession { try groupedMessages .sorted { lhs, rhs in lhs.key.namespace.processingOrder < rhs.key.namespace.processingOrder } .forEach { key, value in - try LibSession + try dependencies.caches[.libSession] .config(for: key, publicKey: publicKey) .mutate { conf in // Merge the messages diff --git a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+Calls.swift b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+Calls.swift index 75f68467d..798276db3 100644 --- a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+Calls.swift +++ b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+Calls.swift @@ -11,13 +11,14 @@ extension MessageReceiver { _ db: Database, threadId: String, threadVariant: SessionThread.Variant, - message: CallMessage + message: CallMessage, + using dependencies: Dependencies ) throws { // Only support calls from contact threads guard threadVariant == .contact else { return } switch message.kind { - case .preOffer: try MessageReceiver.handleNewCallMessage(db, message: message) + case .preOffer: try MessageReceiver.handleNewCallMessage(db, message: message, using: dependencies) case .offer: MessageReceiver.handleOfferCallMessage(db, message: message) case .answer: MessageReceiver.handleAnswerCallMessage(db, message: message) case .provisionalAnswer: break // TODO: Implement @@ -35,7 +36,7 @@ extension MessageReceiver { // MARK: - Specific Handling - private static func handleNewCallMessage(_ db: Database, message: CallMessage) throws { + private static func handleNewCallMessage(_ db: Database, message: CallMessage, using dependencies: Dependencies) throws { SNLog("[Calls] Received pre-offer message.") // Determine whether the app is active based on the prefs rather than the UIApplication state to avoid @@ -57,7 +58,7 @@ extension MessageReceiver { else { return } guard let timestamp = message.sentTimestamp, TimestampUtils.isWithinOneMinute(timestampMs: timestamp) else { // Add missed call message for call offer messages from more than one minute - if let interaction: Interaction = try MessageReceiver.insertCallInfoMessage(db, for: message, state: .missed) { + if let interaction: Interaction = try MessageReceiver.insertCallInfoMessage(db, for: message, state: .missed, using: dependencies) { let thread: SessionThread = try SessionThread .fetchOrCreate(db, id: sender, variant: .contact, shouldBeVisible: nil) @@ -75,7 +76,7 @@ extension MessageReceiver { } guard db[.areCallsEnabled] else { - if let interaction: Interaction = try MessageReceiver.insertCallInfoMessage(db, for: message, state: .permissionDenied) { + if let interaction: Interaction = try MessageReceiver.insertCallInfoMessage(db, for: message, state: .permissionDenied, using: dependencies) { let thread: SessionThread = try SessionThread .fetchOrCreate(db, id: sender, variant: .contact, shouldBeVisible: nil) @@ -112,7 +113,7 @@ extension MessageReceiver { return } - let interaction: Interaction? = try MessageReceiver.insertCallInfoMessage(db, for: message) + let interaction: Interaction? = try MessageReceiver.insertCallInfoMessage(db, for: message, using: dependencies) // Handle UI callManager.showCallUIForCall( @@ -220,7 +221,8 @@ extension MessageReceiver { threadVariant: thread.variant, timestampMs: (messageSentTimestamp * 1000), userPublicKey: getUserHexEncodedPublicKey(db), - openGroup: nil + openGroup: nil, + using: dependencies ), expiresInSeconds: message.expiresInSeconds, expiresStartedAtMs: message.expiresStartedAtMs @@ -257,7 +259,8 @@ extension MessageReceiver { @discardableResult public static func insertCallInfoMessage( _ db: Database, for message: CallMessage, - state: CallMessage.MessageInfo.State? = nil + state: CallMessage.MessageInfo.State? = nil, + using dependencies: Dependencies ) throws -> Interaction? { guard (try? Interaction @@ -300,7 +303,8 @@ extension MessageReceiver { threadVariant: thread.variant, timestampMs: (timestampMs * 1000), userPublicKey: currentUserPublicKey, - openGroup: nil + openGroup: nil, + using: dependencies ), expiresInSeconds: message.expiresInSeconds, expiresStartedAtMs: message.expiresStartedAtMs diff --git a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+DataExtractionNotification.swift b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+DataExtractionNotification.swift index 777b5cb3f..11ee530e0 100644 --- a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+DataExtractionNotification.swift +++ b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+DataExtractionNotification.swift @@ -11,7 +11,8 @@ extension MessageReceiver { threadId: String, threadVariant: SessionThread.Variant, message: DataExtractionNotification, - serverExpirationTimestamp: TimeInterval? + serverExpirationTimestamp: TimeInterval?, + using dependencies: Dependencies ) throws { guard threadVariant == .contact, @@ -29,7 +30,8 @@ extension MessageReceiver { threadVariant: threadVariant, timestampMs: (timestampMs * 1000), userPublicKey: getUserHexEncodedPublicKey(db), - openGroup: nil + openGroup: nil, + using: dependencies ) let messageExpirationInfo: Message.MessageExpirationInfo = Message.getMessageExpirationInfo( threadVariant: threadVariant, diff --git a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+ExpirationTimers.swift b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+ExpirationTimers.swift index 216ba8c08..c05e0b6ec 100644 --- a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+ExpirationTimers.swift +++ b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+ExpirationTimers.swift @@ -11,7 +11,8 @@ extension MessageReceiver { _ db: Database, threadId: String, threadVariant: SessionThread.Variant, - message: ExpirationTimerUpdate + message: ExpirationTimerUpdate, + using dependencies: Dependencies ) throws { guard !Features.useNewDisappearingMessagesConfig else { return } guard @@ -127,7 +128,8 @@ extension MessageReceiver { threadVariant: threadVariant, timestampMs: (timestampMs * 1000), userPublicKey: currentUserPublicKey, - openGroup: nil + openGroup: nil, + using: dependencies ) ).inserted(db) } diff --git a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+VisibleMessages.swift b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+VisibleMessages.swift index 93429876c..4e832979a 100644 --- a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+VisibleMessages.swift +++ b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+VisibleMessages.swift @@ -120,7 +120,8 @@ extension MessageReceiver { associatedWithProto: proto, sender: sender, messageSentTimestamp: messageSentTimestamp, - openGroup: maybeOpenGroup + openGroup: maybeOpenGroup, + using: dependencies ) { return interactionId } @@ -138,7 +139,8 @@ extension MessageReceiver { threadVariant: thread.variant, timestampMs: Int64(messageSentTimestamp * 1000), userPublicKey: currentUserPublicKey, - openGroup: maybeOpenGroup + openGroup: maybeOpenGroup, + using: dependencies ) ) let messageExpirationInfo: Message.MessageExpirationInfo = Message.getMessageExpirationInfo( @@ -375,7 +377,8 @@ extension MessageReceiver { associatedWithProto proto: SNProtoContent, sender: String, messageSentTimestamp: TimeInterval, - openGroup: OpenGroup? + openGroup: OpenGroup?, + using dependencies: Dependencies ) throws -> Int64? { guard let reaction: VisibleMessage.VMReaction = message.reaction, @@ -422,7 +425,8 @@ extension MessageReceiver { threadVariant: thread.variant, timestampMs: timestampMs, userPublicKey: currentUserPublicKey, - openGroup: openGroup + openGroup: openGroup, + using: dependencies ) // Don't notify if the reaction was added before the lastest read timestamp for diff --git a/SessionMessagingKit/Sending & Receiving/MessageReceiver.swift b/SessionMessagingKit/Sending & Receiving/MessageReceiver.swift index 887168d97..6f4f558fd 100644 --- a/SessionMessagingKit/Sending & Receiving/MessageReceiver.swift +++ b/SessionMessagingKit/Sending & Receiving/MessageReceiver.swift @@ -227,13 +227,19 @@ public enum MessageReceiver { message: Message, serverExpirationTimestamp: TimeInterval?, associatedWithProto proto: SNProtoContent, - using dependencies: Dependencies = Dependencies() + using dependencies: Dependencies ) throws { // Check if the message requires an existing conversation (if it does and the conversation isn't in // the config then the message will be dropped) guard !Message.requiresExistingConversation(message: message, threadVariant: threadVariant) || - LibSession.conversationInConfig(db, threadId: threadId, threadVariant: threadVariant, visibleOnly: false) + LibSession.conversationInConfig( + db, + threadId: threadId, + threadVariant: threadVariant, + visibleOnly: false, + using: dependencies + ) else { throw MessageReceiverError.requiredThreadNotInConfig } // Throw if the message is outdated and shouldn't be processed @@ -286,7 +292,8 @@ public enum MessageReceiver { threadId: threadId, threadVariant: threadVariant, message: message, - serverExpirationTimestamp: serverExpirationTimestamp + serverExpirationTimestamp: serverExpirationTimestamp, + using: dependencies ) case let message as ExpirationTimerUpdate: @@ -294,7 +301,8 @@ public enum MessageReceiver { db, threadId: threadId, threadVariant: threadVariant, - message: message + message: message, + using: dependencies ) try MessageReceiver.handleExpirationTimerUpdate( @@ -319,7 +327,8 @@ public enum MessageReceiver { db, threadId: threadId, threadVariant: threadVariant, - message: message + message: message, + using: dependencies ) case let message as MessageRequestResponse: @@ -434,7 +443,7 @@ public enum MessageReceiver { message: Message, threadId: String, threadVariant: SessionThread.Variant, - using dependencies: Dependencies = Dependencies() + using dependencies: Dependencies ) throws { switch message { case is ReadReceipt: return // No visible artifact created so better to keep for more reliable read states @@ -448,7 +457,8 @@ public enum MessageReceiver { db, threadId: threadId, threadVariant: threadVariant, - visibleOnly: true + visibleOnly: true, + using: dependencies ) let canPerformChange: Bool = LibSession.canPerformChange( db, diff --git a/SessionMessagingKit/Sending & Receiving/Pollers/Poller.swift b/SessionMessagingKit/Sending & Receiving/Pollers/Poller.swift index 379814124..c1fd2616e 100644 --- a/SessionMessagingKit/Sending & Receiving/Pollers/Poller.swift +++ b/SessionMessagingKit/Sending & Receiving/Pollers/Poller.swift @@ -216,7 +216,7 @@ public class Poller { } let pollerQueue: DispatchQueue = self.pollerQueue - let configHashes: [String] = LibSession.configHashes(for: swarmPublicKey) + let configHashes: [String] = LibSession.configHashes(for: swarmPublicKey, using: dependencies) // Fetch the messages return LibSession.getSwarm(swarmPublicKey: swarmPublicKey) @@ -324,7 +324,8 @@ public class Poller { calledFromBackgroundPoller: false ) .messages, - publicKey: swarmPublicKey + publicKey: swarmPublicKey, + using: dependencies ) } catch { Log.error("Failed to handle processed config message due to error: \(error).") } @@ -343,7 +344,8 @@ public class Poller { threadVariant: threadVariant, message: messageInfo.message, serverExpirationTimestamp: messageInfo.serverExpirationTimestamp, - associatedWithProto: proto + associatedWithProto: proto, + using: dependencies ) } catch { Log.error("Failed to handle processed message due to error: \(error).") } diff --git a/SessionNotificationServiceExtension/NotificationServiceExtension.swift b/SessionNotificationServiceExtension/NotificationServiceExtension.swift index 783b3e3b8..f0c589d48 100644 --- a/SessionNotificationServiceExtension/NotificationServiceExtension.swift +++ b/SessionNotificationServiceExtension/NotificationServiceExtension.swift @@ -126,7 +126,8 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension data: data ) ], - publicKey: publicKey + publicKey: publicKey, + using: dependencies ) /// Due to the way the `CallMessage` works we need to custom handle it's behaviour within the notification @@ -149,7 +150,8 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension db, threadId: threadId, threadVariant: threadVariant, - message: callMessage + message: callMessage, + using: dependencies ) guard case .preOffer = callMessage.kind else { @@ -163,7 +165,8 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension let interaction: Interaction = try MessageReceiver.insertCallInfoMessage( db, for: callMessage, - state: .permissionDenied + state: .permissionDenied, + using: dependencies ) { let thread: SessionThread = try SessionThread @@ -193,7 +196,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension ) case (true, false): - try MessageReceiver.insertCallInfoMessage(db, for: callMessage) + try MessageReceiver.insertCallInfoMessage(db, for: callMessage, using: dependencies) // Perform any required post-handling logic try MessageReceiver.postHandleMessage( @@ -274,7 +277,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension // MARK: Setup - private func setUpIfNecessary(using dependencies: Dependencies, completion: @escaping () -> Void) { + private func setUpIfNecessary(completion: @escaping () -> Void) { Log.assertOnMainThread() // The NSE will often re-use the same process, so if we're @@ -366,7 +369,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension /// to somehow still have some form of access to the old one private func forceResetup(_ notificationContent: UNMutableNotificationContent) { Storage.reconfigureDatabase() - LibSession.clearMemoryState() + LibSession.clearMemoryState(using: dependencies) dependencies.caches.mutate(cache: .general) { $0.clearCachedUserPublicKey() } self.setUpIfNecessary() { [weak self, dependencies] in diff --git a/SessionSnodeKitTests/_TestUtilities/SSKMockedExtensions.swift b/SessionSnodeKitTests/_TestUtilities/SSKMockedExtensions.swift index 87002f74f..4c93ef751 100644 --- a/SessionSnodeKitTests/_TestUtilities/SSKMockedExtensions.swift +++ b/SessionSnodeKitTests/_TestUtilities/SSKMockedExtensions.swift @@ -1,6 +1,7 @@ // Copyright © 2024 Rangeproof Pty Ltd. All rights reserved. import Foundation +import SessionSnodeKit import SessionUtilitiesKit extension Network.Destination: Mocked { diff --git a/SessionSnodeKitTests/_TestUtilities/SSNMockedExtensions.swift b/SessionSnodeKitTests/_TestUtilities/SSNMockedExtensions.swift deleted file mode 100644 index 4c93ef751..000000000 --- a/SessionSnodeKitTests/_TestUtilities/SSNMockedExtensions.swift +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright © 2024 Rangeproof Pty Ltd. All rights reserved. - -import Foundation -import SessionSnodeKit -import SessionUtilitiesKit - -extension Network.Destination: Mocked { - static var mockValue: Network.Destination = Network.Destination.server( - url: URL(string: "https://oxen.io")!, - method: .get, - headers: nil, - x25519PublicKey: "" - ) -} diff --git a/SessionUtilitiesKit/General/Logging.swift b/SessionUtilitiesKit/General/Logging.swift index bb93f9506..d3fd19692 100644 --- a/SessionUtilitiesKit/General/Logging.swift +++ b/SessionUtilitiesKit/General/Logging.swift @@ -278,7 +278,7 @@ public enum Log { let message: String = message() let logMessage: String = (message.isEmpty ? "Assertion failed." : message) let formattedMessage: String = "[\(filename):\(line) \(function)] \(logMessage)" - custom(.critical, formattedMessage, withPrefixes: true, silenceForTests: false, file: file, function: function, line: line) + custom(.critical, [], formattedMessage, file: file, function: function, line: line) assertionFailure(formattedMessage) } @@ -291,7 +291,7 @@ public enum Log { let filename: String = URL(fileURLWithPath: "\(file)").lastPathComponent let formattedMessage: String = "[\(filename):\(line) \(function)] Must be on main thread." - custom(.critical, formattedMessage, withPrefixes: true, silenceForTests: false, file: file, function: function, line: line) + custom(.critical, [], formattedMessage, file: file, function: function, line: line) assertionFailure(formattedMessage) }