Private
Public Access
1
0

Started working on new conversation / address validation

This commit is contained in:
James Magahern
2021-07-08 13:46:10 -07:00
parent 7a3303da06
commit d814c2e4f6
4 changed files with 113 additions and 2 deletions

View File

@@ -0,0 +1,58 @@
//
// MBIMAliasValidationOperation.m
// MBIMAliasValidationOperation
//
// Created by James Magahern on 7/8/21.
// Copyright © 2021 James Magahern. All rights reserved.
//
#import "MBIMAliasValidationOperation.h"
#import "IMCore_ClassDump.h"
#import "IMFoundation_ClassDump.h"
@implementation MBIMAliasValidationOperation
+ (void)load { [super load]; }
+ (NSString *)endpointName
{
return @"validate";
}
- (void)main
{
NSString *address = [self valueForQueryItemWithName:@"address"];
if ([address length] == 0) {
self.serverCompletionBlock([[HTTPErrorResponse alloc] initWithErrorCode:401]);
return;
}
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)
: IDSCopyIDForPhoneNumber(unformattedAddress);
if (!IDSaddress) {
MBIMLogError(@"Could not get IDS address for: %@", unformattedAddress);
self.serverCompletionBlock([[HTTPErrorResponse alloc] initWithErrorCode:401]);
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),
}]);
});
}
@end