SendMessage: some backwards compatibility
This commit is contained in:
@@ -21,6 +21,118 @@
|
|||||||
return @"sendMessage";
|
return @"sendMessage";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (nullable IMChat *)_existingSingleChatForHandle:(IMHandle *)handle registry:(IMChatRegistry *)registry
|
||||||
|
{
|
||||||
|
if ([registry respondsToSelector:@selector(existingChatWithHandle:allowAlternativeService:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry existingChatWithHandle:allowAlternativeService:");
|
||||||
|
return [registry existingChatWithHandle:handle allowAlternativeService:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([registry respondsToSelector:@selector(existingChatWithHandle:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry existingChatWithHandle:");
|
||||||
|
return [registry existingChatWithHandle:handle];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([registry respondsToSelector:@selector(existingChatForIMHandle:allowRetargeting:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry existingChatForIMHandle:allowRetargeting:");
|
||||||
|
return [registry existingChatForIMHandle:handle allowRetargeting:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([registry respondsToSelector:@selector(existingChatForIMHandle:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry existingChatForIMHandle:");
|
||||||
|
return [registry existingChatForIMHandle:handle];
|
||||||
|
}
|
||||||
|
|
||||||
|
MBIMLogError(@"IMChatRegistry does not support any known single-handle existing chat lookup selector.");
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (nullable IMChat *)_createSingleChatForHandle:(IMHandle *)handle registry:(IMChatRegistry *)registry
|
||||||
|
{
|
||||||
|
if ([registry respondsToSelector:@selector(chatWithHandle:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry chatWithHandle:");
|
||||||
|
return [registry chatWithHandle:handle];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([registry respondsToSelector:@selector(chatForIMHandle:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry chatForIMHandle:");
|
||||||
|
return [registry chatForIMHandle:handle];
|
||||||
|
}
|
||||||
|
|
||||||
|
MBIMLogError(@"IMChatRegistry does not support any known single-handle chat creation selector.");
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (nullable IMChat *)_existingGroupChatForHandles:(NSArray<IMHandle *> *)handles registry:(IMChatRegistry *)registry
|
||||||
|
{
|
||||||
|
if ([registry respondsToSelector:@selector(existingChatWithHandles:allowAlternativeService:groupID:displayName:joinedChatsOnly:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry existingChatWithHandles:allowAlternativeService:groupID:displayName:joinedChatsOnly:");
|
||||||
|
return [registry existingChatWithHandles:handles
|
||||||
|
allowAlternativeService:NO
|
||||||
|
groupID:nil
|
||||||
|
displayName:nil
|
||||||
|
joinedChatsOnly:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([registry respondsToSelector:@selector(existingChatWithHandles:allowAlternativeService:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry existingChatWithHandles:allowAlternativeService:");
|
||||||
|
return [registry existingChatWithHandles:handles allowAlternativeService:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([registry respondsToSelector:@selector(existingChatWithHandles:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry existingChatWithHandles:");
|
||||||
|
return [registry existingChatWithHandles:handles];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([registry respondsToSelector:@selector(existingChatForIMHandles:allowRetargeting:groupID:displayName:joinedChatsOnly:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry existingChatForIMHandles:allowRetargeting:groupID:displayName:joinedChatsOnly:");
|
||||||
|
return [registry existingChatForIMHandles:handles
|
||||||
|
allowRetargeting:NO
|
||||||
|
groupID:nil
|
||||||
|
displayName:nil
|
||||||
|
joinedChatsOnly:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([registry respondsToSelector:@selector(existingChatForIMHandles:allowRetargeting:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry existingChatForIMHandles:allowRetargeting:");
|
||||||
|
return [registry existingChatForIMHandles:handles allowRetargeting:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([registry respondsToSelector:@selector(existingChatForIMHandles:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry existingChatForIMHandles:");
|
||||||
|
return [registry existingChatForIMHandles:handles];
|
||||||
|
}
|
||||||
|
|
||||||
|
MBIMLogError(@"IMChatRegistry does not support any known multi-handle existing chat lookup selector.");
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (nullable IMChat *)_createGroupChatForHandles:(NSArray<IMHandle *> *)handles registry:(IMChatRegistry *)registry
|
||||||
|
{
|
||||||
|
if ([registry respondsToSelector:@selector(chatWithHandles:displayName:joinedChatsOnly:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry chatWithHandles:displayName:joinedChatsOnly:");
|
||||||
|
return [registry chatWithHandles:handles displayName:nil joinedChatsOnly:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([registry respondsToSelector:@selector(chatWithHandles:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry chatWithHandles:");
|
||||||
|
return [registry chatWithHandles:handles];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([registry respondsToSelector:@selector(chatForIMHandles:displayName:joinedChatsOnly:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry chatForIMHandles:displayName:joinedChatsOnly:");
|
||||||
|
return [registry chatForIMHandles:handles displayName:nil joinedChatsOnly:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([registry respondsToSelector:@selector(chatForIMHandles:)]) {
|
||||||
|
MBIMLogInfo(@"Using IMChatRegistry chatForIMHandles:");
|
||||||
|
return [registry chatForIMHandles:handles];
|
||||||
|
}
|
||||||
|
|
||||||
|
MBIMLogError(@"IMChatRegistry does not support any known multi-handle chat creation selector.");
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
- (nullable IMChat *)_chatForHandleIDs:(NSArray<NSString *> *)handleIDs registry:(IMChatRegistry *)registry
|
- (nullable IMChat *)_chatForHandleIDs:(NSArray<NSString *> *)handleIDs registry:(IMChatRegistry *)registry
|
||||||
{
|
{
|
||||||
MBIMLogInfo(@"Resolving send target for handles: %@", handleIDs);
|
MBIMLogInfo(@"Resolving send target for handles: %@", handleIDs);
|
||||||
@@ -44,9 +156,9 @@
|
|||||||
|
|
||||||
if ([handles count] == 1) {
|
if ([handles count] == 1) {
|
||||||
IMHandle *handle = [handles firstObject];
|
IMHandle *handle = [handles firstObject];
|
||||||
IMChat *chat = [registry existingChatWithHandle:handle allowAlternativeService:NO];
|
IMChat *chat = [self _existingSingleChatForHandle:handle registry:registry];
|
||||||
if (!chat) {
|
if (!chat) {
|
||||||
chat = [registry chatWithHandle:handle];
|
chat = [self _createSingleChatForHandle:handle registry:registry];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chat) {
|
if (chat) {
|
||||||
@@ -58,14 +170,9 @@
|
|||||||
return chat;
|
return chat;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMChat *chat = [registry existingChatWithHandles:handles
|
IMChat *chat = [self _existingGroupChatForHandles:handles registry:registry];
|
||||||
allowAlternativeService:NO
|
|
||||||
groupID:nil
|
|
||||||
displayName:nil
|
|
||||||
joinedChatsOnly:YES];
|
|
||||||
|
|
||||||
if (!chat) {
|
if (!chat) {
|
||||||
chat = [registry chatWithHandles:handles displayName:nil joinedChatsOnly:YES];
|
chat = [self _createGroupChatForHandles:handles registry:registry];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chat) {
|
if (chat) {
|
||||||
|
|||||||
Reference in New Issue
Block a user