IOS-797: Configuration sync messages incorrectly updating local config on nil message fields

Configuration sync messages use proto2, so the value for a given field
may or may not exist. When we receive an incoming sync message, we
should only adopt any properties if they're already set. Otherwise we
risk interpreting an unset field as set NO.
This commit is contained in:
Michelle Linington 2020-08-21 16:42:26 -07:00
parent 9e27886d89
commit 44e7e456ca

View File

@ -252,12 +252,23 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
- (void)processIncomingConfigurationSyncMessage:(SSKProtoSyncMessageConfiguration *)syncMessage transaction:(SDSAnyWriteTransaction *)transaction
{
[SSKEnvironment.shared.readReceiptManager setAreReadReceiptsEnabled:syncMessage.readReceipts transaction:transaction];
[Environment.shared.preferences
setShouldShowUnidentifiedDeliveryIndicators:syncMessage.unidentifiedDeliveryIndicators
transaction:transaction];
[self.typingIndicators setTypingIndicatorsEnabledWithValue:syncMessage.typingIndicators transaction:transaction];
[SSKPreferences setAreLinkPreviewsEnabled:syncMessage.linkPreviews transaction:transaction];
if (syncMessage.hasReadReceipts) {
[SSKEnvironment.shared.readReceiptManager setAreReadReceiptsEnabled:syncMessage.readReceipts
transaction:transaction];
}
if (syncMessage.hasUnidentifiedDeliveryIndicators) {
BOOL updatedValue = syncMessage.unidentifiedDeliveryIndicators;
[Environment.shared.preferences setShouldShowUnidentifiedDeliveryIndicators:updatedValue
transaction:transaction];
}
if (syncMessage.hasTypingIndicators) {
[self.typingIndicators setTypingIndicatorsEnabledWithValue:syncMessage.typingIndicators
transaction:transaction];
}
if (syncMessage.hasLinkPreviews) {
[SSKPreferences setAreLinkPreviewsEnabled:syncMessage.linkPreviews
transaction:transaction];
}
[transaction addAsyncCompletion:^{
[[NSNotificationCenter defaultCenter] postNotificationNameAsync:OWSSyncManagerConfigurationSyncDidCompleteNotification