Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ios/ios/src/Users/CMUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,8 @@ typedef void (^CMUserFetchWithMetaCallback)(CMObjectFetchResponse *response);

+ (void)searchUsers:(NSString *)query options:(CMStoreOptions *)options callback:(CMUserFetchWithMetaCallback)callback;

+ (void)searchUsersWithIdentifiers:(NSArray<NSString*>*)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 <tt>callback</tt> block will be called with an array
Expand Down
9 changes: 9 additions & 0 deletions ios/ios/src/Users/CMUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,15 @@ + (void)searchUsers:(NSString *)query callback:(CMUserFetchCallback)callback {
}];
}

+ (void)searchUsersWithIdentifiers:(NSArray<NSString*>*)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);

Expand Down
2 changes: 2 additions & 0 deletions ios/ios/src/Web Services/CMWebService.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ typedef void (^CMWebServiceResultCallback)(id responseBody, NSError *errors, NSU
*/
- (void)searchUsers:(NSString *)query callback:(CMWebServiceUserFetchSuccessCallback)callback;

- (void)searchUsersWithUsersIdentifiers:(NSArray<NSString *>*)identifiersList callback:(CMWebServiceUserFetchSuccessCallback)callback;


- (void)getUsersWithIdentifier:(NSString *)identifier
query:(NSString *)query
Expand Down
26 changes: 26 additions & 0 deletions ios/ios/src/Web Services/CMWebService.m
Original file line number Diff line number Diff line change
Expand Up @@ -1222,13 +1222,15 @@ - (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
query:nil]
appSecret:_appSecret
binaryData:NO
user:nil];

[self executeUserProfileFetchRequest:request callback:callback];

}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -1260,6 +1264,20 @@ - (void)searchUsers:(NSString *)query callback:(CMWebServiceUserFetchSuccessCall
[self executeUserProfileFetchRequest:request callback:callback];
}

- (void)searchUsersWithUsersIdentifiers:(NSArray<NSString*> *)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
Expand All @@ -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
Expand All @@ -1283,6 +1302,8 @@ - (void)getUsersWithIdentifier:(NSString *)identifier
[self executeUserProfileFetchRequestWithMeta:request callback:callback];
}



#pragma - Request queueing and execution

- (void)executeUserProfileFetchRequestWithMeta:(NSMutableURLRequest *)request
Expand Down Expand Up @@ -2259,6 +2280,7 @@ - (NSURL *)constructDataUrlAtUserLevel:(BOOL)atUserLevel
}

- (NSURL *)constructAccountUrlWithUserIdentifier:(NSString *)userId
usersIdentifiers:(NSArray<NSString*> *)usersIdentifiers
function:(CMServerFunction *)function
paging:(CMPagingDescriptor *)paging
sorting:(CMSortDescriptor *)sorting
Expand All @@ -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];
Expand Down