diff --git a/Signal/src/Profiles/OWSProfileManager.m b/Signal/src/Profiles/OWSProfileManager.m index 45a35609c..2517d11f1 100644 --- a/Signal/src/Profiles/OWSProfileManager.m +++ b/Signal/src/Profiles/OWSProfileManager.m @@ -598,6 +598,8 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640; #ifdef DEBUG - (void)clearProfileWhitelist { + DDLogWarn(@"%@ Clearing the profile whitelist.", self.tag); + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ @synchronized(self) { @@ -621,8 +623,20 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640; DDLogError(@"groupProfileWhitelistCache: %zd", self.groupProfileWhitelistCache.count); DDLogError(@"kOWSProfileManager_UserWhitelistCollection: %zd", [self.dbConnection numberOfKeysInCollection:kOWSProfileManager_UserWhitelistCollection]); + [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { + [transaction enumerateKeysInCollection:kOWSProfileManager_UserWhitelistCollection + usingBlock:^(NSString *_Nonnull key, BOOL *_Nonnull stop) { + DDLogError(@"\t profile whitelist user: %@", key); + }]; + }]; DDLogError(@"kOWSProfileManager_GroupWhitelistCollection: %zd", [self.dbConnection numberOfKeysInCollection:kOWSProfileManager_GroupWhitelistCollection]); + [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { + [transaction enumerateKeysInCollection:kOWSProfileManager_GroupWhitelistCollection + usingBlock:^(NSString *_Nonnull key, BOOL *_Nonnull stop) { + DDLogError(@"\t profile whitelist group: %@", key); + }]; + }]; } }); } diff --git a/Signal/src/util/ThreadUtil.h b/Signal/src/util/ThreadUtil.h index 6987fe81d..6b38fc105 100644 --- a/Signal/src/util/ThreadUtil.h +++ b/Signal/src/util/ThreadUtil.h @@ -38,8 +38,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) BOOL hasMoreUnseenMessages; -@property (nonatomic, readonly) BOOL didInsertDynamicInteractions; - - (void)clearUnreadIndicatorState; @end diff --git a/Signal/src/util/ThreadUtil.m b/Signal/src/util/ThreadUtil.m index a19a1b7fc..5cbf2c319 100644 --- a/Signal/src/util/ThreadUtil.m +++ b/Signal/src/util/ThreadUtil.m @@ -28,8 +28,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic) BOOL hasMoreUnseenMessages; -@property (nonatomic) BOOL didInsertDynamicInteractions; - @end #pragma mark - @@ -400,7 +398,10 @@ NS_ASSUME_NONNULL_BEGIN const int kAddToContactsOfferOffset = -2; const int kUnreadIndicatorOfferOffset = -1; - // Ensure dynamic interactions have a non-negative timestamp even if the conversation was empty. + // We want the offers to be the first interactions in their + // conversation's timeline, so we back-date them to slightly before + // the first message - or at an aribtrary old timestamp if the + // conversation has no messages. long long startOfConversationTimestamp = (long long)(firstMessage ? firstMessage.timestampForSorting : 1000); @@ -413,9 +414,6 @@ NS_ASSUME_NONNULL_BEGIN } else if (!existingBlockOffer && shouldHaveBlockOffer) { DDLogInfo(@"Creating block offer for unknown contact"); - // We want the block offer to be the first interaction in their - // conversation's timeline, so we back-date it to slightly before - // the first incoming message (which we know is the first message). uint64_t blockOfferTimestamp = (uint64_t)(startOfConversationTimestamp + kBlockOfferOffset); NSString *recipientId = ((TSContactThread *)thread).contactIdentifier; @@ -424,7 +422,6 @@ NS_ASSUME_NONNULL_BEGIN thread:thread contactId:recipientId]; [offerMessage saveWithTransaction:transaction]; - result.didInsertDynamicInteractions = YES; DDLogInfo(@"%@ Creating block offer: %@ (%llu)", self.tag, @@ -442,9 +439,6 @@ NS_ASSUME_NONNULL_BEGIN DDLogInfo(@"%@ Creating 'add to contacts' offer for unknown contact", self.tag); - // We want the offer to be the first interaction in their - // conversation's timeline, so we back-date it to slightly before - // the first incoming message (which we know is the first message). uint64_t offerTimestamp = (uint64_t)(startOfConversationTimestamp + kAddToContactsOfferOffset); NSString *recipientId = ((TSContactThread *)thread).contactIdentifier; @@ -452,7 +446,6 @@ NS_ASSUME_NONNULL_BEGIN thread:thread contactId:recipientId]; [offerMessage saveWithTransaction:transaction]; - result.didInsertDynamicInteractions = YES; DDLogInfo(@"%@ Creating 'add to contacts' offer: %@ (%llu)", self.tag, @@ -470,15 +463,11 @@ NS_ASSUME_NONNULL_BEGIN DDLogInfo(@"%@ Creating 'add to profile whitelist' offer", self.tag); - // We want the offer to be the first interaction in their - // conversation's timeline, so we back-date it to slightly before - // the first incoming message (which we know is the first message). uint64_t offerTimestamp = (uint64_t)(startOfConversationTimestamp + kAddToProfileWhitelistOfferOffset); TSMessage *offerMessage = [OWSAddToProfileWhitelistOfferMessage addToProfileWhitelistOfferMessage:offerTimestamp thread:thread]; [offerMessage saveWithTransaction:transaction]; - result.didInsertDynamicInteractions = YES; DDLogInfo(@"%@ Creating 'add to profile whitelist' offer: %@ (%llu)", self.tag, @@ -519,7 +508,6 @@ NS_ASSUME_NONNULL_BEGIN hasMoreUnseenMessages:result.hasMoreUnseenMessages missingUnseenSafetyNumberChangeCount:missingUnseenSafetyNumberChangeCount]; [indicator saveWithTransaction:transaction]; - result.didInsertDynamicInteractions = YES; DDLogInfo(@"%@ Creating TSUnreadIndicatorInteraction: %@ (%llu)", self.tag, diff --git a/SignalServiceKit/src/Storage/YapDatabaseConnection+OWS.m b/SignalServiceKit/src/Storage/YapDatabaseConnection+OWS.m index 0a885dc82..957d0d4c8 100644 --- a/SignalServiceKit/src/Storage/YapDatabaseConnection+OWS.m +++ b/SignalServiceKit/src/Storage/YapDatabaseConnection+OWS.m @@ -97,7 +97,7 @@ NS_ASSUME_NONNULL_BEGIN - (NSUInteger)numberOfKeysInCollection:(NSString *)collection { __block NSUInteger result; - [self readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { + [self readWithBlock:^(YapDatabaseReadTransaction *transaction) { result = [transaction numberOfKeysInCollection:collection]; }]; return result;