Private
Public Access
1
0

SendMessage: allows creation of new conversations in addition to replying to guids

This commit is contained in:
James Magahern
2021-07-08 15:35:29 -07:00
parent d814c2e4f6
commit 40fb964cb3
5 changed files with 139 additions and 58 deletions

View File

@@ -29,9 +29,6 @@
}
NSString *unformattedAddress = IMStripFormattingFromAddress(address);
IMAccount *iMessageAccount = [[IMAccountController sharedInstance] bestAccountForService:[IMServiceImpl iMessageService]];
IMHandle *handle = [iMessageAccount imHandleWithID:unformattedAddress];
BOOL isEmailAddress = IMStringIsEmail(unformattedAddress);
NSString *IDSaddress = isEmailAddress ? IDSCopyIDForEmailAddress(unformattedAddress)
@@ -43,16 +40,30 @@
return;
}
IMChatCalculateServiceForSendingNewComposeMaybeForce(
@[ IDSaddress ], nil, nil, NO, isEmailAddress, NO, NO, NO, nil,
^(BOOL allAddressesiMessageCapable, NSDictionary *availabilityPerRecipient, BOOL checkedServer, NSError *error) {
NSLog(@"Capable: %d", allAddressesiMessageCapable);
NSLog(@"Avail: %@", availabilityPerRecipient);
self.serverCompletionBlock([MBIMJSONDataResponse responseWithJSONObject:@{
@"capable" : @(allAddressesiMessageCapable),
}]);
__block IMChat *existingChat = nil;
dispatch_sync([[self class] sharedIMAccessQueue], ^{
IMAccount *iMessageAccount = [[IMAccountController sharedInstance] bestAccountForService:[IMServiceImpl iMessageService]];
IMHandle *handle = [iMessageAccount imHandleWithID:unformattedAddress];
if (handle) {
existingChat = [[IMChatRegistry sharedInstance] existingChatForIMHandle:handle];
}
});
IMChatCalculateServiceForSendingNewComposeMaybeForce(
@[ IDSaddress ], nil, nil, NO, isEmailAddress, YES, NO, NO, nil,
^(BOOL allAddressesiMessageCapable, NSDictionary *availabilityPerRecipient, BOOL checkedServer, NSError *error) {
NSMutableDictionary *response = [NSMutableDictionary dictionaryWithDictionary:@{
@"capable" : @(allAddressesiMessageCapable),
@"idsAddress" : IDSaddress,
}];
if ([existingChat guid]) {
[response setObject:[existingChat guid] forKey:@"existingGuid"];
}
self.serverCompletionBlock([MBIMJSONDataResponse responseWithJSONObject:response]);
});
}
@end