Respond to CR.

This commit is contained in:
Matthew Chen 2018-11-01 16:06:03 -04:00
parent 3011175cef
commit 3eab5b82cc
4 changed files with 16 additions and 9 deletions

View File

@ -103,7 +103,7 @@ NS_ASSUME_NONNULL_BEGIN
[SignalRecipient markRecipientAsRegisteredAndGet:recipientId transaction:transaction];
[recipients addObject:recipient];
} else {
[SignalRecipient removeUnregisteredRecipient:recipientId transaction:transaction];
[SignalRecipient markRecipientAsUnregistered:recipientId transaction:transaction];
}
}
}];

View File

@ -10,10 +10,11 @@ NS_ASSUME_NONNULL_BEGIN
//
// a) It serves as a cache of "known" Signal accounts. When the service indicates
// that an account exists, we make sure that an instance of SignalRecipient exists
// for that recipient id (using mark as registered).
// When the service indicates that an account does not exist, we remove any
// SignalRecipient.
// b) We hang the "known device list" for known signal accounts on this entity.
// for that recipient id (using mark as registered) and has at least one device.
// When the service indicates that an account does not exist, we remove any devices
// from that SignalRecipient - but do not remove it from the database.
// Note that SignalRecipients without any devices are not considered registered.
//// b) We hang the "known device list" for known signal accounts on this entity.
@interface SignalRecipient : TSYapDatabaseObject
@property (nonatomic, readonly) NSOrderedSet *devices;
@ -41,7 +42,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)markRecipientAsRegistered:(NSString *)recipientId
deviceId:(UInt32)deviceId
transaction:(YapDatabaseReadWriteTransaction *)transaction;
+ (void)removeUnregisteredRecipient:(NSString *)recipientId transaction:(YapDatabaseReadWriteTransaction *)transaction;
+ (void)markRecipientAsUnregistered:(NSString *)recipientId transaction:(YapDatabaseReadWriteTransaction *)transaction;
@end

View File

@ -141,7 +141,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssertDebug(devicesToAdd.count > 0 || devicesToRemove.count > 0);
// Add before we remove, since removeDevicesFromRecipient:...
// can removeUnregisteredRecipient:... if the recipient has
// can markRecipientAsUnregistered:... if the recipient has
// no devices left.
if (devicesToAdd.count > 0) {
[self addDevicesToRegisteredRecipient:[NSSet setWithArray:devicesToAdd] transaction:transaction];
@ -192,6 +192,12 @@ NS_ASSUME_NONNULL_BEGIN
- (void)removeWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
// We need to distinguish between "users we know to be unregistered" and
// "users whose registration status is unknown". The former correspond to
// instances of SignalRecipient with no devices. The latter do not
// correspond to an instance of SignalRecipient in the database (although
// they may correspond to an "unsaved" instance of SignalRecipient built
// by getOrBuildUnsavedRecipientForRecipientId.
OWSFailDebug(@"Don't call removeWithTransaction.");
[super removeWithTransaction:transaction];
@ -256,7 +262,7 @@ NS_ASSUME_NONNULL_BEGIN
}
}
+ (void)removeUnregisteredRecipient:(NSString *)recipientId transaction:(YapDatabaseReadWriteTransaction *)transaction
+ (void)markRecipientAsUnregistered:(NSString *)recipientId transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssertDebug(transaction);
OWSAssertDebug(recipientId.length > 0);

View File

@ -817,7 +817,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
return;
}
[SignalRecipient removeUnregisteredRecipient:recipient.recipientId transaction:transaction];
[SignalRecipient markRecipientAsUnregistered:recipient.recipientId transaction:transaction];
[[TSInfoMessage userNotRegisteredMessageInThread:thread recipientId:recipient.recipientId]
saveWithTransaction:transaction];