diff --git a/SignalServiceKit/src/Contacts/SignalRecipient.h b/SignalServiceKit/src/Contacts/SignalRecipient.h index 39b3bd44f..2151829d9 100644 --- a/SignalServiceKit/src/Contacts/SignalRecipient.h +++ b/SignalServiceKit/src/Contacts/SignalRecipient.h @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)removeDevices:(NSSet *)set; @property (nonatomic, nullable) NSString *relay; -@property (nonatomic, retain) NSMutableOrderedSet *devices; +@property (nonatomic) NSMutableOrderedSet *devices; - (BOOL)supportsVoice; // This property indicates support for both WebRTC audio and video calls. diff --git a/SignalServiceKit/src/Contacts/SignalRecipient.m b/SignalServiceKit/src/Contacts/SignalRecipient.m index dc71f3a01..3e08e4558 100644 --- a/SignalServiceKit/src/Contacts/SignalRecipient.m +++ b/SignalServiceKit/src/Contacts/SignalRecipient.m @@ -23,7 +23,23 @@ NS_ASSUME_NONNULL_BEGIN return self; } - _devices = [NSMutableOrderedSet orderedSetWithObject:[NSNumber numberWithInt:1]]; + OWSAssert([TSAccountManager localNumber].length > 0); + if ([[TSAccountManager localNumber] isEqualToString:textSecureIdentifier]) { + // Default to no devices. + // + // This instance represents our own account and is used for sending + // sync message to linked devices. We shouldn't have any linked devices + // yet when we create the "self" SignalRecipient, and we don't need to + // send sync messages to the primary - we ARE the primary. + _devices = [NSMutableOrderedSet new]; + } else { + // Default to sending to just primary device. + // + // OWSMessageSender will correct this if it is wrong the next time + // we send a message to this recipient. + _devices = [NSMutableOrderedSet orderedSetWithObject:@(1)]; + } + _relay = [relay isEqualToString:@""] ? nil : relay; return self; diff --git a/SignalServiceKit/src/Messages/OWSMessageSender.m b/SignalServiceKit/src/Messages/OWSMessageSender.m index 9ac276096..7ba8024a5 100644 --- a/SignalServiceKit/src/Messages/OWSMessageSender.m +++ b/SignalServiceKit/src/Messages/OWSMessageSender.m @@ -978,16 +978,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; // of new secondary devices when this message send fails. DDLogWarn(@"%@ sync message has no device messages but account has secondary devices.", self.logTag); } else if (hasDeviceMessages) { - for (NSDictionary *deviceMessage in deviceMessages) { - NSNumber *_Nullable deviceId = deviceMessage[@"destinationDeviceId"]; - if (deviceId && [deviceId isKindOfClass:[NSNumber class]] && [deviceId isEqualToNumber:@(1)]) { - DDLogWarn(@"%@ trying to sending sync message to primary device, presumably because user has just " - @"registered.", - self.logTag); - } else { - OWSFail(@"%@ sync message has device messages for unknown secondary devices.", self.logTag); - } - } + OWSFail(@"%@ sync message has device messages for unknown secondary devices.", self.logTag); } else { // Account has secondary devices; proceed as usual. }