Private
Public Access
1
0
Files
Kordophone/kordophone/Bridge/Operations/MBIMAliasValidationOperation.m

59 lines
1.9 KiB
Mathematica
Raw Normal View History

//
// 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