Add documentation

pull/56/head
Niels Andriesse 6 years ago
parent 8c3a5f6bd8
commit dafb1469a8

@ -926,25 +926,12 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
BOOL isFriendRequestMessage = [message isKindOfClass:LKFriendRequestMessage.class];
[[LKAPI getDestinationsFor:contactID]
.thenOn(OWSDispatch.sendingQueue, ^(NSArray<LKDestination *> *destinations) {
// Use a best attempt approach for multi device for now
NSArray *slaveDestinations = [destinations filtered:^BOOL(NSObject *object) {
LKDestination *destination = [object as:LKDestination.class];
return [destination.kind isEqual:@"slave"];
}];
for (LKDestination *slaveDestination in slaveDestinations) {
TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:slaveDestination.hexEncodedPublicKey];
if (thread.isContactFriend || isSilentMessage || (isFriendRequestMessage && contactID == slaveDestination.hexEncodedPublicKey)) {
OWSMessageSend *messageSendCopy = [messageSend copyWithDestination:slaveDestination];
[self sendMessage:messageSendCopy];
} else {
OWSMessageSend *friendRequestMessage = [self getMultiDeviceFriendRequestMessageForHexEncodedPublicKey:slaveDestination.hexEncodedPublicKey];
[self sendMessage:friendRequestMessage];
}
}
// Get master destination
LKDestination *masterDestination = [destinations filtered:^BOOL(NSObject *object) {
LKDestination *destination = [object as:LKDestination.class];
return [destination.kind isEqual:@"master"];
}].firstObject;
// Send to master destination
if (masterDestination != nil) {
TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:masterDestination.hexEncodedPublicKey];
if (thread.isContactFriend || isSilentMessage || (isFriendRequestMessage && contactID == masterDestination.hexEncodedPublicKey)) {
@ -955,6 +942,22 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
[self sendMessage:friendRequestMessage];
}
}
// Get slave destinations
NSArray *slaveDestinations = [destinations filtered:^BOOL(NSObject *object) {
LKDestination *destination = [object as:LKDestination.class];
return [destination.kind isEqual:@"slave"];
}];
// Send to slave destinations (using a best attempt approach (i.e. ignoring the message send result) for now)
for (LKDestination *slaveDestination in slaveDestinations) {
TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:slaveDestination.hexEncodedPublicKey];
if (thread.isContactFriend || isSilentMessage || (isFriendRequestMessage && contactID == slaveDestination.hexEncodedPublicKey)) {
OWSMessageSend *messageSendCopy = [messageSend copyWithDestination:slaveDestination];
[self sendMessage:messageSendCopy];
} else {
OWSMessageSend *friendRequestMessage = [self getMultiDeviceFriendRequestMessageForHexEncodedPublicKey:slaveDestination.hexEncodedPublicKey];
[self sendMessage:friendRequestMessage];
}
}
})
.catchOn(OWSDispatch.sendingQueue, ^(NSError *error) {
[self messageSendDidFail:messageSend deviceMessages:@{} statusCode:0 error:error responseData:nil];

Loading…
Cancel
Save