Skip to content

Commit

Permalink
Merge pull request #714 from matrix-org/riot_2686
Browse files Browse the repository at this point in the history
MXAutoDiscovery: Add initWithUrl contructor
  • Loading branch information
manuroe authored Sep 2, 2019
2 parents f83f60a + ccfc9dd commit 44c9a3d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Improvements:
* MXIdentityService: Support identity server v2 API. Handle identity server v2 API authentification and use the hashed v2 lookup API for 3PIDs (vector-im/riot-ios#2603 and /vector-im/riot-ios#2652).
* MXHTTPClient: Add access token renewal plus request retry mechanism.
* MXHTTPClient: Do not retry requests if the host is not valid.
* MXAutoDiscovery: Add initWithUrl contructor

API break:
* MXRestClient: Remove identity server requests. Now MXIdentityService is used to perform identity server requests.
Expand Down
8 changes: 8 additions & 0 deletions MatrixSDK/Data/AutoDiscovery/MXAutoDiscovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ NS_ASSUME_NONNULL_BEGIN

@interface MXAutoDiscovery : NSObject

/**
Create a `MXAutoDiscovery` instance.
@param url the homeserver url (ex: "https://matrix.org").
@return a `MXAutoDiscovery` instance.
*/
- (nullable instancetype)initWithUrl:(NSString *)url;

/**
Create a `MXAutoDiscovery` instance.
Expand Down
17 changes: 11 additions & 6 deletions MatrixSDK/Data/AutoDiscovery/MXAutoDiscovery.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,12 @@ @interface MXAutoDiscovery ()

@implementation MXAutoDiscovery

- (nullable instancetype)initWithDomain:(NSString *)domain
- (nullable instancetype)initWithUrl:(NSString *)url
{
self = [super init];
if (self)
{
NSURLComponents *components = [NSURLComponents new];
components.scheme = @"https";
components.host = domain;

restClient = [[MXRestClient alloc] initWithHomeServer:components.URL.absoluteString
restClient = [[MXRestClient alloc] initWithHomeServer:url
andOnUnrecognizedCertificateBlock:nil];

// The .well-known/matrix/client API is often just a static file returned with no content type.
Expand All @@ -49,6 +45,15 @@ - (nullable instancetype)initWithDomain:(NSString *)domain
return self;
}

- (nullable instancetype)initWithDomain:(NSString *)domain
{
NSURLComponents *components = [NSURLComponents new];
components.scheme = @"https";
components.host = domain;

return [self initWithUrl:components.URL.absoluteString];
}

- (MXHTTPOperation *)findClientConfig:(void (^)(MXDiscoveredClientConfig * _Nonnull))complete
failure:(void (^)(NSError * _Nonnull))failure
{
Expand Down

0 comments on commit 44c9a3d

Please sign in to comment.