Add support for fetching room list
FossilOrigin-Name: 092c122c690b6e64c67120c6c153e82fceb484078dd3d713d56e01ce13c3902d
This commit is contained in:
parent
77a2d20fc7
commit
c7fc35fb0f
11 changed files with 258 additions and 61 deletions
|
@ -23,6 +23,7 @@
|
|||
#import "MTXClient.h"
|
||||
#import "MTXRequest.h"
|
||||
|
||||
#import "MTXFetchRoomListFailedException.h"
|
||||
#import "MTXLoginFailedException.h"
|
||||
#import "MTXLogoutFailedException.h"
|
||||
|
||||
|
@ -204,4 +205,30 @@ validateHomeserver(OFURL *homeserver)
|
|||
|
||||
objc_autoreleasePoolPop(pool);
|
||||
}
|
||||
|
||||
- (void)asyncFetchRoomList: (mtx_client_room_list_block_t)block
|
||||
{
|
||||
void *pool = objc_autoreleasePoolPush();
|
||||
MTXRequest *request =
|
||||
[self requestWithPath: @"/_matrix/client/r0/joined_rooms"];
|
||||
[request asyncPerformWithBlock: ^ (mtx_response_t response,
|
||||
int statusCode, id exception) {
|
||||
if (exception != nil) {
|
||||
block(nil, exception);
|
||||
return;
|
||||
}
|
||||
|
||||
if (statusCode != 200 || response[@"joined_rooms"] == nil) {
|
||||
block(nil, [MTXFetchRoomListFailedException
|
||||
exceptionWithClient: self
|
||||
statusCode: statusCode
|
||||
response: response]);
|
||||
return;
|
||||
}
|
||||
|
||||
block(response[@"joined_rooms"], nil);
|
||||
}];
|
||||
|
||||
objc_autoreleasePoolPop(pool);
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue