SendMessage: allows creation of new conversations in addition to replying to guids
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user