Skip to content

Commit

Permalink
Join Room: Support via parameters to better handle federation
Browse files Browse the repository at this point in the history
  • Loading branch information
manuroe committed Jul 8, 2019
1 parent c896d5b commit 87b1e15
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changes in 0.8.7 (2019-xx-xx)
Improvements:
* RoomVC: When replying, use a "Reply" button instead of "Send".
* RoomVC: New message actions (#2394).
* Join Room: Support via parameters to better handle federation (#2547).
* Reactions: Display existing reactions below the message (#2396).
* Menu actions: Display message time (#2463).
* Reactions Menu: Fix position (#2447).
Expand Down
19 changes: 17 additions & 2 deletions Riot/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -2324,6 +2324,7 @@ - (BOOL)handleUniversalLinkFragment:(NSString*)fragment
[homeViewController stopActivityIndicator];

roomPreviewData = [[RoomPreviewData alloc] initWithRoomId:roomIdOrAlias emailInvitationParams:queryParams andSession:account.mxSession];
roomPreviewData.viaServers = queryParams[@"via"];
[self showRoomPreview:roomPreviewData];
}
else
Expand Down Expand Up @@ -2522,8 +2523,22 @@ - (void)parseUniversalLinkFragment:(NSString*)fragment outPathParams:(NSArray<NS
{
value = [value stringByReplacingOccurrencesOfString:@"+" withString:@" "];
value = [value stringByRemovingPercentEncoding];

queryParams[key] = value;

if ([key isEqualToString:@"via"])
{
// Special case the via parameter
// As we can have several of them, store each value into an array
if (!queryParams[key])
{
queryParams[key] = [NSMutableArray array];
}

[queryParams[key] addObject:value];
}
else
{
queryParams[key] = value;
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions Riot/Model/Room/RoomPreviewData.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
*/
@property (nonatomic) NSString *eventId;

/**
In case of preview, the server names to try and join through in addition to those
that are automatically chosen.
*/
@property (nonatomic) NSArray<NSString*> *viaServers;

/**
Preview information.
*/
Expand Down
5 changes: 3 additions & 2 deletions Riot/Modules/Common/Recents/RecentsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1815,8 +1815,9 @@ - (void)joinARoom
self->currentAlert = nil;

[self.activityIndicator startAnimating];

self->currentRequest = [self.mainSession joinRoom:roomAliasOrId success:^(MXRoom *room) {

// TODO
self->currentRequest = [self.mainSession joinRoom:roomAliasOrId viaServers:nil success:^(MXRoom *room) {

self->currentRequest = nil;
[self.activityIndicator stopAnimating];
Expand Down
5 changes: 3 additions & 2 deletions Riot/Modules/Room/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,8 @@ - (BOOL)isIRCStyleCommand:(NSString*)string
// Check
if (roomAlias.length)
{
[self.mainSession joinRoom:roomAlias success:^(MXRoom *room) {
// TODO: /join command does not support via parameters yet
[self.mainSession joinRoom:roomAlias viaServers:nil success:^(MXRoom *room) {

// Show the room
[[AppDelegate theDelegate] showRoom:room.roomId andEventId:nil withMatrixSession:self.mainSession];
Expand Down Expand Up @@ -3685,7 +3686,7 @@ - (void)roomTitleView:(RoomTitleView*)titleView recognizeTapGesture:(UITapGestur
}

// Note in case of simple link to a room the signUrl param is nil
[self joinRoomWithRoomIdOrAlias:roomIdOrAlias andSignUrl:roomPreviewData.emailInvitation.signUrl completion:^(BOOL succeed) {
[self joinRoomWithRoomIdOrAlias:roomIdOrAlias viaServers:roomPreviewData.viaServers andSignUrl:roomPreviewData.emailInvitation.signUrl completion:^(BOOL succeed) {

if (succeed)
{
Expand Down

0 comments on commit 87b1e15

Please sign in to comment.