diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 1861510d1..8e6a9287c 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -123,8 +123,8 @@ 346129FF1FD5F31400532771 /* OWS103EnableVideoCalling.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129F21FD5F31400532771 /* OWS103EnableVideoCalling.m */; }; 34612A001FD5F31400532771 /* OWS105AttachmentFilePaths.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129F31FD5F31400532771 /* OWS105AttachmentFilePaths.h */; }; 34612A011FD5F31400532771 /* OWS104CreateRecipientIdentities.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129F41FD5F31400532771 /* OWS104CreateRecipientIdentities.h */; }; - 34612A061FD7238600532771 /* OWSContactsSyncing.h in Headers */ = {isa = PBXBuildFile; fileRef = 34612A041FD7238500532771 /* OWSContactsSyncing.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 34612A071FD7238600532771 /* OWSContactsSyncing.m in Sources */ = {isa = PBXBuildFile; fileRef = 34612A051FD7238500532771 /* OWSContactsSyncing.m */; }; + 34612A061FD7238600532771 /* OWSSyncManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 34612A041FD7238500532771 /* OWSSyncManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 34612A071FD7238600532771 /* OWSSyncManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 34612A051FD7238500532771 /* OWSSyncManager.m */; }; 34641E182088D7E900E2EDE5 /* OWSScreenLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34641E172088D7E900E2EDE5 /* OWSScreenLock.swift */; }; 34641E1F2088DA6D00E2EDE5 /* SAEScreenLockViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34641E1E2088DA6D00E2EDE5 /* SAEScreenLockViewController.m */; }; 3466087220E550F400AFFE73 /* ConversationStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3466087120E550F300AFFE73 /* ConversationStyle.swift */; }; @@ -754,8 +754,8 @@ 346129F21FD5F31400532771 /* OWS103EnableVideoCalling.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWS103EnableVideoCalling.m; sourceTree = ""; }; 346129F31FD5F31400532771 /* OWS105AttachmentFilePaths.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWS105AttachmentFilePaths.h; sourceTree = ""; }; 346129F41FD5F31400532771 /* OWS104CreateRecipientIdentities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWS104CreateRecipientIdentities.h; sourceTree = ""; }; - 34612A041FD7238500532771 /* OWSContactsSyncing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSContactsSyncing.h; sourceTree = ""; }; - 34612A051FD7238500532771 /* OWSContactsSyncing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSContactsSyncing.m; sourceTree = ""; }; + 34612A041FD7238500532771 /* OWSSyncManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSSyncManager.h; sourceTree = ""; }; + 34612A051FD7238500532771 /* OWSSyncManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSSyncManager.m; sourceTree = ""; }; 34641E1020878FAF00E2EDE5 /* OWSWindowManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSWindowManager.m; sourceTree = ""; }; 34641E1120878FB000E2EDE5 /* OWSWindowManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSWindowManager.h; sourceTree = ""; }; 34641E172088D7E900E2EDE5 /* OWSScreenLock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OWSScreenLock.swift; sourceTree = ""; }; @@ -1645,8 +1645,8 @@ children = ( 346129A21FD1F09100532771 /* OWSContactsManager.h */, 346129A31FD1F09100532771 /* OWSContactsManager.m */, - 34612A041FD7238500532771 /* OWSContactsSyncing.h */, - 34612A051FD7238500532771 /* OWSContactsSyncing.m */, + 34612A041FD7238500532771 /* OWSSyncManager.h */, + 34612A051FD7238500532771 /* OWSSyncManager.m */, 346129AE1FD1F5D900532771 /* SystemContactsFetcher.swift */, ); path = contacts; @@ -2517,7 +2517,7 @@ 34AC09EC211B39B100997B47 /* OWSTableViewController.h in Headers */, 451F8A3C1FD71392005CB9DA /* UIUtil.h in Headers */, 346129D61FD20ADC00532771 /* UIViewController+OWS.h in Headers */, - 34612A061FD7238600532771 /* OWSContactsSyncing.h in Headers */, + 34612A061FD7238600532771 /* OWSSyncManager.h in Headers */, 34480B571FD0A7A400BC14EF /* OWSScrubbingLogFormatter.h in Headers */, 346129FC1FD5F31400532771 /* OWS101ExistingUsersBlockOnIdentityChange.h in Headers */, 34AC09F2211B39B100997B47 /* OWSViewController.h in Headers */, @@ -3250,7 +3250,7 @@ 34AC09F3211B39B100997B47 /* NewNonContactConversationViewController.m in Sources */, 34AC09FA211B39B100997B47 /* SharingThreadPickerViewController.m in Sources */, 45F59A082028E4FB00E8D2B0 /* OWSAudioSession.swift in Sources */, - 34612A071FD7238600532771 /* OWSContactsSyncing.m in Sources */, + 34612A071FD7238600532771 /* OWSSyncManager.m in Sources */, 450C801220AD1D5B00F3A091 /* UIDevice+featureSupport.swift in Sources */, 451F8A471FD715BA005CB9DA /* OWSAvatarBuilder.m in Sources */, 34AC09E7211B39B100997B47 /* MessageApprovalViewController.swift in Sources */, diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index a6aa9f4c6..11a676fdd 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -24,11 +24,11 @@ #import #import #import -#import #import #import #import #import +#import #import #import #import @@ -193,8 +193,8 @@ static NSTimeInterval launchStartedAt; screenBlockingWindow:OWSScreenLockUI.sharedManager.screenBlockingWindow]; [OWSScreenLockUI.sharedManager startObserving]; - // Ensure OWSContactsSyncing is instantiated. - [OWSContactsSyncing sharedManager]; + // Ensure OWSSyncManager is instantiated. + [OWSSyncManager shared]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(storageIsReady) diff --git a/Signal/src/ViewControllers/DebugUI/DebugUISyncMessages.m b/Signal/src/ViewControllers/DebugUI/DebugUISyncMessages.m index 208997d1d..405cfed90 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUISyncMessages.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUISyncMessages.m @@ -142,21 +142,8 @@ NS_ASSUME_NONNULL_BEGIN + (void)sendConfigurationSyncMessage { - __block BOOL areReadReceiptsEnabled; - [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { - areReadReceiptsEnabled = - [[OWSReadReceiptManager sharedManager] areReadReceiptsEnabledWithTransaction:transaction]; - }]; - - OWSSyncConfigurationMessage *syncConfigurationMessage = - [[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled]; - [self.messageSender enqueueMessage:syncConfigurationMessage - success:^{ - OWSLogInfo(@"Successfully sent Configuration response syncMessage."); - } - failure:^(NSError *error) { - OWSLogError(@"Failed to send Configuration response syncMessage with error: %@", error); - }]; + [NSNotificationCenter.defaultCenter postNotificationNameAsync:NSNotificationName_SyncConfigurationNeeded + object:nil]; } @end diff --git a/Signal/test/mocks/MockEnvironment.h b/Signal/test/mocks/MockEnvironment.h index 035dcb8bd..cbb121adb 100644 --- a/Signal/test/mocks/MockEnvironment.h +++ b/Signal/test/mocks/MockEnvironment.h @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic) OWSContactsManager *contactsManager; @property (nonatomic) OWSPreferences *preferences; -@property (nonatomic) OWSContactsSyncing *contactsSyncing; +@property (nonatomic) OWSSyncManager *syncManager; @property (nonatomic) OWSSounds *sounds; @property (nonatomic) LockInteractionController *lockInteractionController; @property (nonatomic) OWSWindowManager *windowManager; diff --git a/Signal/test/mocks/MockEnvironment.m b/Signal/test/mocks/MockEnvironment.m index 80c616a0e..99ef2ba07 100644 --- a/Signal/test/mocks/MockEnvironment.m +++ b/Signal/test/mocks/MockEnvironment.m @@ -4,7 +4,7 @@ #import "MockEnvironment.h" #import "OWSBackup.h" -#import "OWSContactsSyncing.h" +#import "OWSSyncManager.h" #import "OWSWindowManager.h" #import #import @@ -28,13 +28,13 @@ NS_ASSUME_NONNULL_BEGIN // TODO: We should probably mock this out. OWSPreferences *preferences = [OWSPreferences new]; - OWSContactsSyncing *contactsSyncing = [[OWSContactsSyncing alloc] initDefault]; + OWSSyncManager *syncManager = [[OWSSyncManager alloc] initDefault]; OWSSounds *sounds = [[OWSSounds alloc] initWithPrimaryStorage:primaryStorage]; LockInteractionController *lockInteractionController = [[LockInteractionController alloc] initDefault]; OWSWindowManager *windowManager = [[OWSWindowManager alloc] initDefault]; self = [super initWithPreferences:preferences - contactsSyncing:contactsSyncing + syncManager:syncManager sounds:sounds lockInteractionController:lockInteractionController windowManager:windowManager]; diff --git a/SignalMessaging/SignalMessaging.h b/SignalMessaging/SignalMessaging.h index 119718eb5..276d1b5cd 100644 --- a/SignalMessaging/SignalMessaging.h +++ b/SignalMessaging/SignalMessaging.h @@ -28,7 +28,6 @@ FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[]; #import #import #import -#import #import #import #import @@ -40,6 +39,7 @@ FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[]; #import #import #import +#import #import #import #import diff --git a/SignalMessaging/contacts/OWSContactsSyncing.h b/SignalMessaging/contacts/OWSSyncManager.h similarity index 82% rename from SignalMessaging/contacts/OWSContactsSyncing.h rename to SignalMessaging/contacts/OWSSyncManager.h index c359a4519..4fbba73de 100644 --- a/SignalMessaging/contacts/OWSContactsSyncing.h +++ b/SignalMessaging/contacts/OWSSyncManager.h @@ -9,13 +9,13 @@ NS_ASSUME_NONNULL_BEGIN @class OWSMessageSender; @class OWSProfileManager; -@interface OWSContactsSyncing : NSObject +@interface OWSSyncManager : NSObject - (instancetype)init NS_UNAVAILABLE; - (instancetype)initDefault NS_DESIGNATED_INITIALIZER; -+ (instancetype)sharedManager; ++ (instancetype)shared; @end diff --git a/SignalMessaging/contacts/OWSContactsSyncing.m b/SignalMessaging/contacts/OWSSyncManager.m similarity index 69% rename from SignalMessaging/contacts/OWSContactsSyncing.m rename to SignalMessaging/contacts/OWSSyncManager.m index 8117512e0..ab4bf8998 100644 --- a/SignalMessaging/contacts/OWSContactsSyncing.m +++ b/SignalMessaging/contacts/OWSSyncManager.m @@ -2,25 +2,27 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "OWSContactsSyncing.h" +#import "OWSSyncManager.h" #import "Environment.h" #import "OWSContactsManager.h" +#import "OWSPreferences.h" #import "OWSProfileManager.h" +#import "OWSReadReceiptManager.h" #import #import #import #import +#import #import #import #import NS_ASSUME_NONNULL_BEGIN -NSString *const kOWSPrimaryStorageOWSContactsSyncingCollection = @"kTSStorageManagerOWSContactsSyncingCollection"; -NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey - = @"kTSStorageManagerOWSContactsSyncingLastMessageKey"; +NSString *const kOWSPrimaryStorageOWSSyncManagerCollection = @"kTSStorageManagerOWSSyncManagerCollection"; +NSString *const kOWSPrimaryStorageOWSSyncManagerLastMessageKey = @"kTSStorageManagerOWSSyncManagerLastMessageKey"; -@interface OWSContactsSyncing () +@interface OWSSyncManager () @property (nonatomic, readonly) dispatch_queue_t serialQueue; @@ -28,17 +30,15 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey @end -@implementation OWSContactsSyncing +@implementation OWSSyncManager -+ (instancetype)sharedManager -{ - OWSAssertDebug(Environment.shared.contactsSyncing); ++ (instancetype)shared { + OWSAssertDebug(Environment.shared.syncManager); - return Environment.shared.contactsSyncing; + return Environment.shared.syncManager; } -- (instancetype)initDefault -{ +- (instancetype)initDefault { self = [super init]; if (!self) { @@ -55,12 +55,15 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey selector:@selector(profileKeyDidChange:) name:kNSNotificationName_ProfileKeyDidChange object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(syncConfigurationNeeded:) + name:NSNotificationName_SyncConfigurationNeeded + object:nil]; return self; } -- (void)dealloc -{ +- (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } @@ -90,10 +93,9 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey return SSKEnvironment.shared.profileManager; } -#pragma mark - +#pragma mark - Notifications -- (void)signalAccountsDidChange:(id)notification -{ +- (void)signalAccountsDidChange:(id)notification { OWSAssertIsOnMainThread(); [self sendSyncContactsMessageIfPossible]; @@ -105,15 +107,21 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey [self sendSyncContactsMessageIfPossible]; } -- (YapDatabaseConnection *)editingDatabaseConnection -{ +- (void)syncConfigurationNeeded:(id)notification { + OWSAssertIsOnMainThread(); + + [self sendConfigurationSyncMessage]; +} + +#pragma mark - + +- (YapDatabaseConnection *)editingDatabaseConnection { return OWSPrimaryStorage.sharedManager.dbReadWriteConnection; } #pragma mark - Methods -- (void)sendSyncContactsMessageIfNecessary -{ +- (void)sendSyncContactsMessageIfNecessary { OWSAssertIsOnMainThread(); if (!self.serialQueue) { @@ -121,7 +129,6 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey } dispatch_async(self.serialQueue, ^{ - if (self.isRequestInFlight) { // De-bounce. It's okay if we ignore some new changes; // `sendSyncContactsMessageIfPossible` is called fairly @@ -138,8 +145,8 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey __block NSData *_Nullable lastMessageData; [self.editingDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { messageData = [syncContactsMessage buildPlainTextAttachmentDataWithTransaction:transaction]; - lastMessageData = [transaction objectForKey:kOWSPrimaryStorageOWSContactsSyncingLastMessageKey - inCollection:kOWSPrimaryStorageOWSContactsSyncingCollection]; + lastMessageData = [transaction objectForKey:kOWSPrimaryStorageOWSSyncManagerLastMessageKey + inCollection:kOWSPrimaryStorageOWSSyncManagerCollection]; }]; if (!messageData) { @@ -162,8 +169,8 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey OWSLogInfo(@"Successfully sent contacts sync message."); [self.editingDatabaseConnection setObject:messageData - forKey:kOWSPrimaryStorageOWSContactsSyncingLastMessageKey - inCollection:kOWSPrimaryStorageOWSContactsSyncingCollection]; + forKey:kOWSPrimaryStorageOWSSyncManagerLastMessageKey + inCollection:kOWSPrimaryStorageOWSSyncManagerCollection]; dispatch_async(self.serialQueue, ^{ self.isRequestInFlight = NO; @@ -179,8 +186,7 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey }); } -- (void)sendSyncContactsMessageIfPossible -{ +- (void)sendSyncContactsMessageIfPossible { OWSAssertIsOnMainThread(); if (!self.contactsManager.isSetup) { @@ -193,6 +199,24 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey } } +- (void)sendConfigurationSyncMessage { + DDLogInfo(@""); + + BOOL areReadReceiptsEnabled = SSKEnvironment.shared.readReceiptManager.areReadReceiptsEnabled; + BOOL showUnidentifiedDeliveryIndicators = Environment.shared.preferences.shouldShowUnidentifiedDeliveryIndicators; + + OWSSyncConfigurationMessage *syncConfigurationMessage = + [[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled + showUnidentifiedDeliveryIndicators:showUnidentifiedDeliveryIndicators]; + [self.messageSender enqueueMessage:syncConfigurationMessage + success:^{ + OWSLogInfo(@"Send configuration sync message succeeded."); + } + failure:^(NSError *error) { + OWSLogError(@"Send configuration sync message failed with error: %@", error); + }]; +} + @end NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/environment/AppSetup.m b/SignalMessaging/environment/AppSetup.m index 48c1009c2..9106a8d2d 100644 --- a/SignalMessaging/environment/AppSetup.m +++ b/SignalMessaging/environment/AppSetup.m @@ -82,13 +82,13 @@ NS_ASSUME_NONNULL_BEGIN OWSOutgoingReceiptManager *outgoingReceiptManager = [[OWSOutgoingReceiptManager alloc] initWithPrimaryStorage:primaryStorage]; - OWSContactsSyncing *contactsSyncing = [[OWSContactsSyncing alloc] initDefault]; + OWSSyncManager *syncManager = [[OWSSyncManager alloc] initDefault]; OWSSounds *sounds = [[OWSSounds alloc] initWithPrimaryStorage:primaryStorage]; LockInteractionController *lockInteractionController = [[LockInteractionController alloc] initDefault]; OWSWindowManager *windowManager = [[OWSWindowManager alloc] initDefault]; [Environment setShared:[[Environment alloc] initWithPreferences:preferences - contactsSyncing:contactsSyncing + syncManager:syncManager sounds:sounds lockInteractionController:lockInteractionController windowManager:windowManager]]; diff --git a/SignalMessaging/environment/Environment.h b/SignalMessaging/environment/Environment.h index 95d494732..231a360e8 100644 --- a/SignalMessaging/environment/Environment.h +++ b/SignalMessaging/environment/Environment.h @@ -6,9 +6,9 @@ @class LockInteractionController; @class OWSContactsManager; -@class OWSContactsSyncing; @class OWSPreferences; @class OWSSounds; +@class OWSSyncManager; @class OWSWindowManager; /** @@ -24,14 +24,14 @@ - (instancetype)init NS_UNAVAILABLE; - (instancetype)initWithPreferences:(OWSPreferences *)preferences - contactsSyncing:(OWSContactsSyncing *)contactsSyncing + syncManager:(OWSSyncManager *)syncManager sounds:(OWSSounds *)sounds lockInteractionController:(LockInteractionController *)lockInteractionController windowManager:(OWSWindowManager *)windowManager; @property (nonatomic, readonly) OWSContactsManager *contactsManager; @property (nonatomic, readonly) OWSPreferences *preferences; -@property (nonatomic, readonly) OWSContactsSyncing *contactsSyncing; +@property (nonatomic, readonly) OWSSyncManager *syncManager; @property (nonatomic, readonly) OWSSounds *sounds; @property (nonatomic, readonly) LockInteractionController *lockInteractionController; @property (nonatomic, readonly) OWSWindowManager *windowManager; diff --git a/SignalMessaging/environment/Environment.m b/SignalMessaging/environment/Environment.m index c53a12edc..b75c59114 100644 --- a/SignalMessaging/environment/Environment.m +++ b/SignalMessaging/environment/Environment.m @@ -13,7 +13,7 @@ static Environment *sharedEnvironment = nil; @property (nonatomic) OWSContactsManager *contactsManager; @property (nonatomic) OWSPreferences *preferences; -@property (nonatomic) OWSContactsSyncing *contactsSyncing; +@property (nonatomic) OWSSyncManager *syncManager; @property (nonatomic) OWSSounds *sounds; @property (nonatomic) LockInteractionController *lockInteractionController; @property (nonatomic) OWSWindowManager *windowManager; @@ -49,7 +49,7 @@ static Environment *sharedEnvironment = nil; } - (instancetype)initWithPreferences:(OWSPreferences *)preferences - contactsSyncing:(OWSContactsSyncing *)contactsSyncing + syncManager:(OWSSyncManager *)syncManager sounds:(OWSSounds *)sounds lockInteractionController:(LockInteractionController *)lockInteractionController windowManager:(OWSWindowManager *)windowManager { @@ -59,13 +59,13 @@ static Environment *sharedEnvironment = nil; } OWSAssertDebug(preferences); - OWSAssertDebug(contactsSyncing); + OWSAssertDebug(syncManager); OWSAssertDebug(sounds); OWSAssertDebug(lockInteractionController); OWSAssertDebug(windowManager); _preferences = preferences; - _contactsSyncing = contactsSyncing; + _syncManager = syncManager; _sounds = sounds; _lockInteractionController = lockInteractionController; _windowManager = windowManager; diff --git a/SignalMessaging/utils/OWSPreferences.m b/SignalMessaging/utils/OWSPreferences.m index 303be9e58..c7eb41c2e 100644 --- a/SignalMessaging/utils/OWSPreferences.m +++ b/SignalMessaging/utils/OWSPreferences.m @@ -6,6 +6,7 @@ #import #import #import +#import #import #import #import @@ -199,6 +200,9 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste - (void)setShouldShowUnidentifiedDeliveryIndicators:(BOOL)value { [self setValueForKey:OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators toValue:@(value)]; + + [NSNotificationCenter.defaultCenter postNotificationNameAsync:NSNotificationName_SyncConfigurationNeeded + object:nil]; } #pragma mark - Calling diff --git a/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncConfigurationMessage.h b/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncConfigurationMessage.h index 51a87cf9d..5482c3339 100644 --- a/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncConfigurationMessage.h +++ b/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncConfigurationMessage.h @@ -6,11 +6,14 @@ NS_ASSUME_NONNULL_BEGIN +extern NSString *const NSNotificationName_SyncConfigurationNeeded; + @interface OWSSyncConfigurationMessage : OWSOutgoingSyncMessage - (instancetype)init NS_UNAVAILABLE; -- (instancetype)initWithReadReceiptsEnabled:(BOOL)readReceiptsEnabled NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithReadReceiptsEnabled:(BOOL)readReceiptsEnabled + showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators NS_DESIGNATED_INITIALIZER; - (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER; @end diff --git a/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncConfigurationMessage.m b/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncConfigurationMessage.m index ddfd53820..33576c962 100644 --- a/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncConfigurationMessage.m +++ b/SignalServiceKit/src/Messages/DeviceSyncing/OWSSyncConfigurationMessage.m @@ -7,22 +7,26 @@ NS_ASSUME_NONNULL_BEGIN +NSString *const NSNotificationName_SyncConfigurationNeeded = @"NSNotificationName_SyncConfigurationNeeded"; + @interface OWSSyncConfigurationMessage () @property (nonatomic, readonly) BOOL areReadReceiptsEnabled; +@property (nonatomic, readonly) BOOL showUnidentifiedDeliveryIndicators; @end @implementation OWSSyncConfigurationMessage - (instancetype)initWithReadReceiptsEnabled:(BOOL)areReadReceiptsEnabled -{ + showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators { self = [super init]; if (!self) { return nil; } _areReadReceiptsEnabled = areReadReceiptsEnabled; + _showUnidentifiedDeliveryIndicators = showUnidentifiedDeliveryIndicators; return self; } @@ -36,6 +40,7 @@ NS_ASSUME_NONNULL_BEGIN { SSKProtoSyncMessageConfigurationBuilder *configurationBuilder = [SSKProtoSyncMessageConfiguration builder]; configurationBuilder.readReceipts = self.areReadReceiptsEnabled; + configurationBuilder.unidentifiedDeliveryIndicators = self.showUnidentifiedDeliveryIndicators; NSError *error; SSKProtoSyncMessageConfiguration *_Nullable configurationProto = [configurationBuilder buildAndReturnError:&error]; diff --git a/SignalServiceKit/src/Messages/OWSMessageManager.m b/SignalServiceKit/src/Messages/OWSMessageManager.m index 61cf9f362..cb9d032c0 100644 --- a/SignalServiceKit/src/Messages/OWSMessageManager.m +++ b/SignalServiceKit/src/Messages/OWSMessageManager.m @@ -7,6 +7,7 @@ #import "AppReadiness.h" #import "ContactsManagerProtocol.h" #import "MimeTypeUtil.h" +#import "NSNotificationCenter+OWS.h" #import "NotificationsProtocol.h" #import "OWSAttachmentsProcessor.h" #import "OWSBlockingManager.h" @@ -848,17 +849,8 @@ NS_ASSUME_NONNULL_BEGIN OWSLogInfo(@"Received request for block list"); [self.blockingManager syncBlockList]; } else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeConfiguration) { - BOOL areReadReceiptsEnabled = - [[OWSReadReceiptManager sharedManager] areReadReceiptsEnabledWithTransaction:transaction]; - OWSSyncConfigurationMessage *syncConfigurationMessage = - [[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled]; - [self.messageSender enqueueMessage:syncConfigurationMessage - success:^{ - OWSLogInfo(@"Successfully sent Configuration response syncMessage."); - } - failure:^(NSError *error) { - OWSLogError(@"Failed to send Configuration response syncMessage with error: %@", error); - }]; + [NSNotificationCenter.defaultCenter postNotificationNameAsync:NSNotificationName_SyncConfigurationNeeded + object:nil]; } else { OWSLogWarn(@"ignoring unsupported sync request message"); } diff --git a/SignalServiceKit/src/Messages/OWSReadReceiptManager.m b/SignalServiceKit/src/Messages/OWSReadReceiptManager.m index aa6c21913..d8625396f 100644 --- a/SignalServiceKit/src/Messages/OWSReadReceiptManager.m +++ b/SignalServiceKit/src/Messages/OWSReadReceiptManager.m @@ -571,15 +571,8 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE forKey:OWSReadReceiptManagerAreReadReceiptsEnabled inCollection:OWSReadReceiptManagerCollection]; - OWSSyncConfigurationMessage *syncConfigurationMessage = - [[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:value]; - [self.messageSender enqueueMessage:syncConfigurationMessage - success:^{ - OWSLogInfo(@"Successfully sent Configuration syncMessage."); - } - failure:^(NSError *error) { - OWSLogError(@"Failed to send Configuration syncMessage with error: %@", error); - }]; + [NSNotificationCenter.defaultCenter postNotificationNameAsync:NSNotificationName_SyncConfigurationNeeded + object:nil]; self.areReadReceiptsEnabledCached = @(value); } diff --git a/SignalShareExtension/ShareViewController.swift b/SignalShareExtension/ShareViewController.swift index af4d690f2..bc6c5eff1 100644 --- a/SignalShareExtension/ShareViewController.swift +++ b/SignalShareExtension/ShareViewController.swift @@ -104,8 +104,8 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed // We don't need to use "screen protection" in the SAE. - // Ensure OWSContactsSyncing is instantiated. - OWSContactsSyncing.sharedManager() + // Ensure OWSSyncManager is instantiated. + OWSSyncManager.shared() NotificationCenter.default.addObserver(self, selector: #selector(storageIsReady), diff --git a/SignalShareExtension/SignalShareExtension-Bridging-Header.h b/SignalShareExtension/SignalShareExtension-Bridging-Header.h index 7cb3cc22f..e8f71533e 100644 --- a/SignalShareExtension/SignalShareExtension-Bridging-Header.h +++ b/SignalShareExtension/SignalShareExtension-Bridging-Header.h @@ -14,9 +14,9 @@ #import #import #import -#import #import #import +#import #import #import #import