From dc92d26f45032d03993e3365bf94202ebc52a7fa Mon Sep 17 00:00:00 2001 From: Bohdan Shcherbyna Date: Fri, 30 Jun 2017 15:47:22 +0300 Subject: [PATCH 1/4] add 'searchUsersWithUsersIdentifiers:(NSArray *)identifiersList callback:(CMWebServiceUserFetchSuccessCallback)callback' method --- ios/ios/src/Users/CMUser.m | 9 +++++++++ ios/ios/src/Web Services/CMWebService.h | 2 ++ ios/ios/src/Web Services/CMWebService.m | 26 +++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/ios/ios/src/Users/CMUser.m b/ios/ios/src/Users/CMUser.m index 6f7b01ca..d236de42 100644 --- a/ios/ios/src/Users/CMUser.m +++ b/ios/ios/src/Users/CMUser.m @@ -769,6 +769,15 @@ + (void)searchUsers:(NSString *)query callback:(CMUserFetchCallback)callback { }]; } ++ (void)searchUsers:(NSArray*)usersIdentifiers callback:(CMUserFetchCallback)callback { + NSParameterAssert(callback); + [[CMWebService sharedWebService] searchUsersWithUsersIdentifiers:usersIdentifiers callback:^(NSDictionary *results, NSDictionary *errors, NSNumber *count) { + NSArray *users = [CMObjectDecoder decodeObjects:results]; + [self cacheMultipleUsers:users]; + callback(users, errors); + }]; +} + + (void)userWithIdentifier:(NSString *)identifier callback:(CMUserFetchCallback)callback { NSParameterAssert(callback); diff --git a/ios/ios/src/Web Services/CMWebService.h b/ios/ios/src/Web Services/CMWebService.h index 688cabd7..85173d36 100644 --- a/ios/ios/src/Web Services/CMWebService.h +++ b/ios/ios/src/Web Services/CMWebService.h @@ -560,6 +560,8 @@ typedef void (^CMWebServiceResultCallback)(id responseBody, NSError *errors, NSU */ - (void)searchUsers:(NSString *)query callback:(CMWebServiceUserFetchSuccessCallback)callback; +- (void)searchUsersWithUsersIdentifiers:(NSArray*)identifiersList callback:(CMWebServiceUserFetchSuccessCallback)callback; + - (void)getUsersWithIdentifier:(NSString *)identifier query:(NSString *)query diff --git a/ios/ios/src/Web Services/CMWebService.m b/ios/ios/src/Web Services/CMWebService.m index 00b1d4b2..1fc59dbf 100644 --- a/ios/ios/src/Web Services/CMWebService.m +++ b/ios/ios/src/Web Services/CMWebService.m @@ -1222,6 +1222,7 @@ - (void)resetForgottenPasswordForUser:(CMUser *)user callback:(CMWebServiceUserA - (void)getAllUsersWithCallback:(CMWebServiceUserFetchSuccessCallback)callback { NSMutableURLRequest *request = [self constructHTTPRequestWithVerb:@"GET" URL:[self constructAccountUrlWithUserIdentifier:nil + usersIdentifiers:nil function:nil paging:nil sorting:nil @@ -1229,6 +1230,7 @@ - (void)getAllUsersWithCallback:(CMWebServiceUserFetchSuccessCallback)callback { appSecret:_appSecret binaryData:NO user:nil]; + [self executeUserProfileFetchRequest:request callback:callback]; } @@ -1237,6 +1239,7 @@ - (void)getUserProfileWithIdentifier:(NSString *)identifier callback:(CMWebServiceUserFetchSuccessCallback)callback { NSMutableURLRequest *request = [self constructHTTPRequestWithVerb:@"GET" URL:[self constructAccountUrlWithUserIdentifier:identifier + usersIdentifiers:nil function:nil paging:nil sorting:nil @@ -1250,6 +1253,7 @@ - (void)getUserProfileWithIdentifier:(NSString *)identifier - (void)searchUsers:(NSString *)query callback:(CMWebServiceUserFetchSuccessCallback)callback { NSMutableURLRequest *request = [self constructHTTPRequestWithVerb:@"GET" URL:[self constructAccountUrlWithUserIdentifier:nil + usersIdentifiers:nil function:nil paging:nil sorting:nil @@ -1260,6 +1264,20 @@ - (void)searchUsers:(NSString *)query callback:(CMWebServiceUserFetchSuccessCall [self executeUserProfileFetchRequest:request callback:callback]; } +- (void)searchUsersWithUsersIdentifiers:(NSArray *)identifiersList callback:(CMWebServiceUserFetchSuccessCallback)callback { + NSMutableURLRequest *request = [self constructHTTPRequestWithVerb:@"GET" + URL:[self constructAccountUrlWithUserIdentifier:nil + usersIdentifiers:identifiersList + function:nil + paging:nil + sorting:nil + query:nil] + appSecret:_appSecret + binaryData:NO + user:nil]; + [self executeUserProfileFetchRequest:request callback:callback]; +} + - (void)getUsersWithIdentifier:(NSString *)identifier query:(NSString *)query ServerSideFunction:(CMServerFunction *)function @@ -1271,6 +1289,7 @@ - (void)getUsersWithIdentifier:(NSString *)identifier NSMutableURLRequest *request = [self constructHTTPRequestWithVerb:@"GET" URL:[self constructAccountUrlWithUserIdentifier:identifier + usersIdentifiers:nil function:function paging:paging sorting:sorting @@ -1283,6 +1302,8 @@ - (void)getUsersWithIdentifier:(NSString *)identifier [self executeUserProfileFetchRequestWithMeta:request callback:callback]; } + + #pragma - Request queueing and execution - (void)executeUserProfileFetchRequestWithMeta:(NSMutableURLRequest *)request @@ -2259,6 +2280,7 @@ - (NSURL *)constructDataUrlAtUserLevel:(BOOL)atUserLevel } - (NSURL *)constructAccountUrlWithUserIdentifier:(NSString *)userId + usersIdentifiers:(NSArray *)usersIdentifiers function:(CMServerFunction *)function paging:(CMPagingDescriptor *)paging sorting:(CMSortDescriptor *)sorting @@ -2270,6 +2292,10 @@ - (NSURL *)constructAccountUrlWithUserIdentifier:(NSString *)userId } else if (query) { url = [url URLByAppendingPathComponent:@"search"]; url = [url URLByAppendingAndEncodingQueryParameter:@"p" andValue:query]; + } else if (usersIdentifiers) { + NSString * userIdentifiersQuery = [usersIdentifiers componentsJoinedByString:@","]; + url = [url URLByAppendingPathComponent:@"/"]; + url = [url URLByAppendingAndEncodingQueryParameter:@"ids" andValue:userIdentifiersQuery]; } NSMutableArray *queryComponents = [NSMutableArray array]; From 3cc25f0b72ed8992157ca8e0f2cf3550eb7d2a93 Mon Sep 17 00:00:00 2001 From: Bohdan Shcherbyna Date: Fri, 30 Jun 2017 15:53:39 +0300 Subject: [PATCH 2/4] rename method --- Podfile.lock | 2 +- ios/cloudmine-ios.xcodeproj/project.pbxproj | 4 ++-- ios/ios/src/Users/CMUser.m | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 0e8fa364..daffaaca 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -35,4 +35,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 881f5095800c61e7eca88dd1b4cace5c5050c2e9 -COCOAPODS: 1.0.1 +COCOAPODS: 1.2.1 diff --git a/ios/cloudmine-ios.xcodeproj/project.pbxproj b/ios/cloudmine-ios.xcodeproj/project.pbxproj index c57c336a..4ce7a5fb 100644 --- a/ios/cloudmine-ios.xcodeproj/project.pbxproj +++ b/ios/cloudmine-ios.xcodeproj/project.pbxproj @@ -1069,7 +1069,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; 7A87314F14BB0A0A000D6DEA /* Build Static Libs */ = { @@ -1170,7 +1170,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; BAA7BC150F1A4FDD944A2FD4 /* [CP] Copy Pods Resources */ = { diff --git a/ios/ios/src/Users/CMUser.m b/ios/ios/src/Users/CMUser.m index d236de42..76adb599 100644 --- a/ios/ios/src/Users/CMUser.m +++ b/ios/ios/src/Users/CMUser.m @@ -769,7 +769,7 @@ + (void)searchUsers:(NSString *)query callback:(CMUserFetchCallback)callback { }]; } -+ (void)searchUsers:(NSArray*)usersIdentifiers callback:(CMUserFetchCallback)callback { ++ (void)searchUsersWithIdentifiers:(NSArray*)usersIdentifiers callback:(CMUserFetchCallback)callback { NSParameterAssert(callback); [[CMWebService sharedWebService] searchUsersWithUsersIdentifiers:usersIdentifiers callback:^(NSDictionary *results, NSDictionary *errors, NSNumber *count) { NSArray *users = [CMObjectDecoder decodeObjects:results]; From 0bf2bb79b7ca8d773df7bdbdbd63d5d637983ec4 Mon Sep 17 00:00:00 2001 From: Bohdan Shcherbyna Date: Fri, 30 Jun 2017 15:59:40 +0300 Subject: [PATCH 3/4] make + (void)searchUsersWithIdentifiers:(NSArray*)usersIdentifiers callback:(CMUserFetchCallback)callback public --- ios/ios/src/Users/CMUser.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ios/ios/src/Users/CMUser.h b/ios/ios/src/Users/CMUser.h index be2dd5bc..41103a22 100644 --- a/ios/ios/src/Users/CMUser.h +++ b/ios/ios/src/Users/CMUser.h @@ -627,6 +627,8 @@ typedef void (^CMUserFetchWithMetaCallback)(CMObjectFetchResponse *response); + (void)searchUsers:(NSString *)query options:(CMStoreOptions *)options callback:(CMUserFetchWithMetaCallback)callback; ++ (void)searchUsersWithIdentifiers:(NSArray*)usersIdentifiers callback:(CMUserFetchCallback)callback + /** * Asynchronously search all profiles of users of this app for matching fields. This will download the profiles of all matching users of your app, and is useful for displaying * and filtering lists of people to share with or running analytics on your users yourself. On completion, the callback block will be called with an array From 151deaa7a0dbdae4633fb7b063a288381fd96ab2 Mon Sep 17 00:00:00 2001 From: Bohdan Shcherbyna Date: Fri, 30 Jun 2017 16:06:43 +0300 Subject: [PATCH 4/4] fix building --- ios/ios/src/Users/CMUser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/ios/src/Users/CMUser.h b/ios/ios/src/Users/CMUser.h index 41103a22..6bdf443f 100644 --- a/ios/ios/src/Users/CMUser.h +++ b/ios/ios/src/Users/CMUser.h @@ -627,7 +627,7 @@ typedef void (^CMUserFetchWithMetaCallback)(CMObjectFetchResponse *response); + (void)searchUsers:(NSString *)query options:(CMStoreOptions *)options callback:(CMUserFetchWithMetaCallback)callback; -+ (void)searchUsersWithIdentifiers:(NSArray*)usersIdentifiers callback:(CMUserFetchCallback)callback ++ (void)searchUsersWithIdentifiers:(NSArray*)usersIdentifiers callback:(CMUserFetchCallback)callback; /** * Asynchronously search all profiles of users of this app for matching fields. This will download the profiles of all matching users of your app, and is useful for displaying