Started working on new conversation / address validation
This commit is contained in:
17
kordophone/Bridge/Operations/MBIMAliasValidationOperation.h
Normal file
17
kordophone/Bridge/Operations/MBIMAliasValidationOperation.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// MBIMAliasValidationOperation.h
|
||||
// MBIMAliasValidationOperation
|
||||
//
|
||||
// Created by James Magahern on 7/8/21.
|
||||
// Copyright © 2021 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMBridgeOperation.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MBIMAliasValidationOperation : MBIMBridgeOperation
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
58
kordophone/Bridge/Operations/MBIMAliasValidationOperation.m
Normal file
58
kordophone/Bridge/Operations/MBIMAliasValidationOperation.m
Normal 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
|
||||
Reference in New Issue
Block a user