Add ProfileManager protocol

This commit is contained in:
Max Radermacher 2024-01-08 13:30:25 -06:00 committed by GitHub
parent 1e75cc2ae4
commit 14927beeaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 75 additions and 32 deletions

View File

@ -681,6 +681,8 @@
503AECCD29B2B88600642F66 /* VoiceMessageConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503AECC929B2B22E00642F66 /* VoiceMessageConstants.swift */; };
503B47222AF0569B00978266 /* PublicKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503B471E2AF0569A00978266 /* PublicKey.swift */; };
503B47232AF0569B00978266 /* ECKeyPair.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503B471F2AF0569A00978266 /* ECKeyPair.swift */; };
503BD2892B44D666009624FC /* ProfileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503BD2882B44D666009624FC /* ProfileManager.swift */; };
503BD28B2B44DA64009624FC /* OWSFakeProfileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503BD28A2B44DA64009624FC /* OWSFakeProfileManager.swift */; };
503BDDB4296F3E2C00FED3B2 /* SystemContactsDataProviderTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503BDDB3296F3E2C00FED3B2 /* SystemContactsDataProviderTest.swift */; };
503BDDB6296F5BE100FED3B2 /* ContactReminderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503BDDB5296F5BE100FED3B2 /* ContactReminderTableViewCell.swift */; };
503C2F432977752B00217527 /* OWSURLSessionEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503C2F422977752B00217527 /* OWSURLSessionEndpoint.swift */; };
@ -3324,6 +3326,8 @@
503AECC929B2B22E00642F66 /* VoiceMessageConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceMessageConstants.swift; sourceTree = "<group>"; };
503B471E2AF0569A00978266 /* PublicKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublicKey.swift; sourceTree = "<group>"; };
503B471F2AF0569A00978266 /* ECKeyPair.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ECKeyPair.swift; sourceTree = "<group>"; };
503BD2882B44D666009624FC /* ProfileManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileManager.swift; sourceTree = "<group>"; };
503BD28A2B44DA64009624FC /* OWSFakeProfileManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OWSFakeProfileManager.swift; sourceTree = "<group>"; };
503BDDB3296F3E2C00FED3B2 /* SystemContactsDataProviderTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemContactsDataProviderTest.swift; sourceTree = "<group>"; };
503BDDB5296F5BE100FED3B2 /* ContactReminderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactReminderTableViewCell.swift; sourceTree = "<group>"; };
503C2F422977752B00217527 /* OWSURLSessionEndpoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OWSURLSessionEndpoint.swift; sourceTree = "<group>"; };
@ -9793,6 +9797,7 @@
F9C5CA06289453B100548EEE /* NotificationsProtocol.h */,
664657402AC4FB720099DE1C /* NotificationsProtocolSwift.swift */,
F9C5CA04289453B100548EEE /* OWSCallMessageHandler.h */,
503BD2882B44D666009624FC /* ProfileManager.swift */,
F9C5CA02289453B100548EEE /* ProfileManagerProtocol.h */,
F9C5CA05289453B100548EEE /* ProtoUtils.h */,
F9C5CA01289453B100548EEE /* ProtoUtils.m */,
@ -10320,6 +10325,7 @@
F9C5CB88289453B200548EEE /* NoopPendingReadReceiptRecorder.swift */,
F9C5CB8F289453B200548EEE /* OWSFakeProfileManager.h */,
F9C5CB83289453B200548EEE /* OWSFakeProfileManager.m */,
503BD28A2B44DA64009624FC /* OWSFakeProfileManager.swift */,
F9C5CB8E289453B200548EEE /* OWSMockSyncManager.swift */,
F9C5CB89289453B200548EEE /* TestAppContext.h */,
F9C5CB95289453B200548EEE /* TestAppContext.m */,
@ -13043,6 +13049,7 @@
F9C5CE49289453B400548EEE /* OWSError.swift in Sources */,
F937EDA429746DA20003AF3F /* OWSFail.swift in Sources */,
F9C5CE53289453B400548EEE /* OWSFakeProfileManager.m in Sources */,
503BD28B2B44DA64009624FC /* OWSFakeProfileManager.swift in Sources */,
F9C5CDCC289453B400548EEE /* OWSFileSystem.m in Sources */,
F9C5CDD7289453B400548EEE /* OWSFileSystem.swift in Sources */,
667664362A43BBCD00716B84 /* OWSFingerprint.swift in Sources */,
@ -13176,6 +13183,7 @@
6659A0312A7C5B9700066AB7 /* PreKeyUploadBundle.swift in Sources */,
D995546F2AF5668E0001E15C /* ProfileBadgesSnapshot.swift in Sources */,
F9C5CE38289453B400548EEE /* ProfileFetcherJob.swift in Sources */,
503BD2892B44D666009624FC /* ProfileManager.swift in Sources */,
50F77AA02AAA7B8A00FB70C5 /* ProfileWhitelistMerger.swift in Sources */,
F9C5CE1D289453B400548EEE /* Promise+OWS.swift in Sources */,
F9C5CCE6289453B300548EEE /* ProtoUtils.m in Sources */,

View File

@ -284,8 +284,8 @@ public protocol _RegistrationCoordinator_ProfileManagerShim {
public class _RegistrationCoordinator_ProfileManagerWrapper: _RegistrationCoordinator_ProfileManagerShim {
private let manager: ProfileManagerProtocol
public init(_ manager: ProfileManagerProtocol) { self.manager = manager }
private let manager: ProfileManager
public init(_ manager: ProfileManager) { self.manager = manager }
public var hasProfileName: Bool { manager.hasProfileName }

View File

@ -786,13 +786,13 @@ class StorageServiceGroupV2RecordUpdater: StorageServiceRecordUpdater {
private let authedAccount: AuthedAccount
private let blockingManager: BlockingManager
private let groupsV2: GroupsV2Swift
private let profileManager: ProfileManagerProtocol
private let profileManager: ProfileManager
init(
authedAccount: AuthedAccount,
blockingManager: BlockingManager,
groupsV2: GroupsV2Swift,
profileManager: ProfileManagerProtocol
profileManager: ProfileManager
) {
self.authedAccount = authedAccount
self.blockingManager = blockingManager

View File

@ -27,7 +27,7 @@ extension Usernames {
public static func assembleByQuerying(
forRecipient recipient: SignalRecipient,
profileManager: ProfileManagerProtocol,
profileManager: ProfileManager,
contactManager: ContactsManagerProtocol,
transaction: SDSAnyReadTransaction
) -> BetterIdentifierChecker {

View File

@ -458,7 +458,7 @@ NSString *const OWSContactsManagerCollection = @"OWSContactsManagerCollection";
return savedContactNameComponents;
}
return [self.profileManager nameComponentsForProfileWithAddress:address transaction:transaction];
return [self.profileManagerObjC nameComponentsForProfileWithAddress:address transaction:transaction];
}
// TODO: Remove?
@ -503,7 +503,7 @@ NSString *const OWSContactsManagerCollection = @"OWSContactsManagerCollection";
__block NSData *_Nullable data;
[self.databaseStorage readWithBlock:^(SDSAnyReadTransaction *transaction) {
data = [self.profileManager profileAvatarDataForAddress:address transaction:transaction];
data = [self.profileManagerObjC profileAvatarDataForAddress:address transaction:transaction];
}];
return data;
}

View File

@ -7,6 +7,9 @@ import Foundation
import LibSignalClient
import SignalServiceKit
extension OWSProfileManager: ProfileManager {
}
public extension OWSProfileManager {
// The main entry point for updating the local profile. It will:

View File

@ -141,11 +141,21 @@ public extension NSObject {
.shared
}
final var profileManager: ProfileManagerProtocol {
final var profileManagerObjC: ProfileManagerProtocol {
SSKEnvironment.shared.profileManagerRef
}
static var profileManager: ProfileManagerProtocol {
static var profileManagerObjC: ProfileManagerProtocol {
SSKEnvironment.shared.profileManagerRef
}
@nonobjc
final var profileManager: ProfileManager {
SSKEnvironment.shared.profileManagerRef
}
@nonobjc
static var profileManager: ProfileManager {
SSKEnvironment.shared.profileManagerRef
}
@ -563,11 +573,11 @@ public extension Dependencies {
.shared
}
var profileManager: ProfileManagerProtocol {
var profileManager: ProfileManager {
SSKEnvironment.shared.profileManagerRef
}
static var profileManager: ProfileManagerProtocol {
static var profileManager: ProfileManager {
SSKEnvironment.shared.profileManagerRef
}

View File

@ -142,7 +142,7 @@ public class DependenciesBridge {
ows2FAManager: OWS2FAManager,
paymentsEvents: PaymentsEvents,
paymentsHelper: PaymentsHelper,
profileManager: ProfileManagerProtocol,
profileManager: ProfileManager,
receiptManager: OWSReceiptManager,
recipientDatabaseTable: RecipientDatabaseTable,
recipientFetcher: RecipientFetcher,
@ -217,7 +217,7 @@ public class DependenciesBridge {
ows2FAManager: OWS2FAManager,
paymentsEvents: PaymentsEvents,
paymentsHelper: PaymentsHelper,
profileManager: ProfileManagerProtocol,
profileManager: ProfileManager,
receiptManager: OWSReceiptManager,
recipientDatabaseTable: RecipientDatabaseTable,
recipientFetcher: RecipientFetcher,

View File

@ -72,9 +72,9 @@ public protocol _MessageBackup_ProfileManagerShim {
public class _MessageBackup_ProfileManagerWrapper: _MessageBackup_ProfileManagerShim {
private let profileManager: ProfileManagerProtocol
private let profileManager: ProfileManager
public init(_ profileManager: ProfileManagerProtocol) {
public init(_ profileManager: ProfileManager) {
self.profileManager = profileManager
}

View File

@ -238,9 +238,9 @@ protocol _PniHelloWorldManagerImpl_ProfileManager_Shim {
}
class _PniHelloWorldManagerImpl_ProfileManager_Wrapper: _PniHelloWorldManagerImpl_ProfileManager_Shim {
private let profileManager: ProfileManagerProtocol
private let profileManager: ProfileManager
init(_ profileManager: ProfileManagerProtocol) {
init(_ profileManager: ProfileManager) {
self.profileManager = profileManager
}

View File

@ -6,9 +6,9 @@
import Foundation
class ProfileWhitelistMerger: RecipientMergeObserver {
private let profileManager: ProfileManagerProtocol
private let profileManager: ProfileManager
init(profileManager: ProfileManagerProtocol) {
init(profileManager: ProfileManager) {
self.profileManager = profileManager
}

View File

@ -131,7 +131,7 @@ class RecipientMergerImpl: RecipientMerger {
groupMemberStore: GroupMemberStore,
interactionStore: InteractionStore,
pinnedThreadManager: PinnedThreadManager,
profileManager: ProfileManagerProtocol,
profileManager: ProfileManager,
recipientMergeNotifier: RecipientMergeNotifier,
signalServiceAddressCache: SignalServiceAddressCache,
threadAssociatedDataStore: ThreadAssociatedDataStore,

View File

@ -78,7 +78,7 @@ struct HiddenRecipient: Codable, FetchableRecord, PersistableRecord {
/// Manager in charge of reading from and writing to the `HiddenRecipient` table.
public final class RecipientHidingManagerImpl: RecipientHidingManager {
private let profileManager: ProfileManagerProtocol
private let profileManager: ProfileManager
private let storageServiceManager: StorageServiceManager
private let tsAccountManager: TSAccountManager
private let messageSenderJobQueue: MessageSenderJobQueue
@ -87,7 +87,7 @@ public final class RecipientHidingManagerImpl: RecipientHidingManager {
public static let hideListDidChange = Notification.Name("hideListDidChange")
public init(
profileManager: ProfileManagerProtocol,
profileManager: ProfileManager,
storageServiceManager: StorageServiceManager,
tsAccountManager: TSAccountManager,
messageSenderJobQueue: MessageSenderJobQueue

View File

@ -11,7 +11,7 @@ public class AccountAttributesUpdaterImpl: AccountAttributesUpdater {
private let appVersion: AppVersion
private let dateProvider: DateProvider
private let db: DB
private let profileManager: ProfileManagerProtocol
private let profileManager: ProfileManager
private let serviceClient: SignalServiceClient
private let schedulers: Schedulers
private let svrLocalStorage: SVRLocalStorage
@ -25,7 +25,7 @@ public class AccountAttributesUpdaterImpl: AccountAttributesUpdater {
appVersion: AppVersion,
dateProvider: @escaping DateProvider,
db: DB,
profileManager: ProfileManagerProtocol,
profileManager: ProfileManager,
keyValueStoreFactory: KeyValueStoreFactory,
serviceClient: SignalServiceClient,
schedulers: Schedulers,

View File

@ -0,0 +1,9 @@
//
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import Foundation
public protocol ProfileManager: ProfileManagerProtocol {
}

View File

@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (OWSAES256Key *)localProfileKey
{
return self.profileManager.localProfileKey;
return self.profileManagerObjC.localProfileKey;
}
#pragma mark -
@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
// Group threads will return YES if the group is in the whitelist
// Contact threads will return YES if the contact is in the whitelist.
return [self.profileManager isThreadInProfileWhitelist:thread transaction:transaction];
return [self.profileManagerObjC isThreadInProfileWhitelist:thread transaction:transaction];
}
+ (void)addLocalProfileKeyIfNecessary:(TSThread *)thread

View File

@ -35,7 +35,7 @@ public class SSKEnvironment: NSObject {
public let linkPreviewManagerRef: OWSLinkPreviewManager
public let pendingReceiptRecorderRef: PendingReceiptRecorder
public let profileManagerRef: ProfileManagerProtocol
public let profileManagerRef: ProfileManager
public let messageReceiverRef: MessageReceiver
public let blockingManagerRef: BlockingManager
public let remoteConfigManagerRef: RemoteConfigManager
@ -95,7 +95,7 @@ public class SSKEnvironment: NSObject {
linkPreviewManager: OWSLinkPreviewManager,
messageSender: MessageSender,
pendingReceiptRecorder: PendingReceiptRecorder,
profileManager: ProfileManagerProtocol,
profileManager: ProfileManager,
networkManager: NetworkManager,
messageReceiver: MessageReceiver,
blockingManager: BlockingManager,

View File

@ -0,0 +1,13 @@
//
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import Foundation
#if TESTABLE_BUILD
extension OWSFakeProfileManager: ProfileManager {
}
#endif

View File

@ -714,7 +714,7 @@ NSString *NSStringForUserProfileWriter(UserProfileWriter userProfileWriter)
} else {
OWSLogInfo(@"Re-uploading local profile to update profile credential.");
[transaction addAsyncCompletionOffMain:^{
[self.profileManager reuploadLocalProfileWithAuthedAccount:authedAccount];
[self.profileManagerObjC reuploadLocalProfileWithAuthedAccount:authedAccount];
}];
}
}
@ -792,7 +792,7 @@ NSString *NSStringForUserProfileWriter(UserProfileWriter userProfileWriter)
}
if (isLocalUserProfile) {
[self.profileManager localProfileWasUpdated:self];
[self.profileManagerObjC localProfileWasUpdated:self];
[self.subscriptionManager reconcileBadgeStatesWithTransaction:transaction];
}

View File

@ -12,7 +12,7 @@ public struct UsernameQuerier {
private let databaseStorage: SDSDatabaseStorage
private let localUsernameManager: LocalUsernameManager
private let networkManager: NetworkManager
private let profileManager: ProfileManagerProtocol
private let profileManager: ProfileManager
private let recipientFetcher: RecipientFetcher
private let schedulers: Schedulers
private let storageServiceManager: StorageServiceManager
@ -46,7 +46,7 @@ public struct UsernameQuerier {
databaseStorage: SDSDatabaseStorage,
localUsernameManager: LocalUsernameManager,
networkManager: NetworkManager,
profileManager: ProfileManagerProtocol,
profileManager: ProfileManager,
recipientFetcher: RecipientFetcher,
schedulers: Schedulers,
storageServiceManager: StorageServiceManager,