|  |  | @ -1521,7 +1521,22 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; | 
			
		
	
		
		
			
				
					
					|  |  |  |     OWSOutgoingSentMessageTranscript *sentMessageTranscript = |  |  |  |     OWSOutgoingSentMessageTranscript *sentMessageTranscript = | 
			
		
	
		
		
			
				
					
					|  |  |  |         [[OWSOutgoingSentMessageTranscript alloc] initWithOutgoingMessage:message isRecipientUpdate:isRecipientUpdate]; |  |  |  |         [[OWSOutgoingSentMessageTranscript alloc] initWithOutgoingMessage:message isRecipientUpdate:isRecipientUpdate]; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     NSString *recipientId = self.tsAccountManager.localNumber; |  |  |  |     NSString *currentDevice = self.tsAccountManager.localNumber; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     // Loki: Send to the other device, but not self | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     __block NSSet<NSString *> *linkedDevices; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     [self.primaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         linkedDevices = [LKDatabaseUtilities getLinkedDeviceHexEncodedPublicKeysFor:currentDevice in:transaction]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     }]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     NSString *otherDevice; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     for (NSString *device in linkedDevices) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (![device isEqual:currentDevice]) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             otherDevice = device; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             break; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     NSString *recipientId = otherDevice ?: currentDevice; | 
			
		
	
		
		
			
				
					
					|  |  |  |     __block SignalRecipient *recipient; |  |  |  |     __block SignalRecipient *recipient; | 
			
		
	
		
		
			
				
					
					|  |  |  |     [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { |  |  |  |     [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         recipient = [SignalRecipient markRecipientAsRegisteredAndGet:recipientId transaction:transaction]; |  |  |  |         recipient = [SignalRecipient markRecipientAsRegisteredAndGet:recipientId transaction:transaction]; | 
			
		
	
	
		
		
			
				
					|  |  | @ -1550,15 +1565,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; | 
			
		
	
		
		
			
				
					
					|  |  |  |             failure(error); |  |  |  |             failure(error); | 
			
		
	
		
		
			
				
					
					|  |  |  |         }]; |  |  |  |         }]; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     if ([LKMultiDeviceProtocol isMultiDeviceRequiredForMessage:message]) { // Avoid the write transaction if possible |  |  |  |     [self sendMessage:messageSend]; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         dispatch_async(dispatch_get_main_queue(), ^{ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             [self.primaryStorage.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 [LKMultiDeviceProtocol sendMessageToDestinationAndLinkedDevices:messageSend in:transaction]; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             }]; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         }); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     } else { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         [self sendMessage:messageSend]; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | - (NSArray<NSDictionary *> *)throws_deviceMessagesForMessageSend:(OWSMessageSend *)messageSend |  |  |  | - (NSArray<NSDictionary *> *)throws_deviceMessagesForMessageSend:(OWSMessageSend *)messageSend | 
			
		
	
	
		
		
			
				
					|  |  | 
 |