diff --git a/CHANGES.rst b/CHANGES.rst index d2bd2d6a0..7427fef55 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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). diff --git a/Riot/AppDelegate.m b/Riot/AppDelegate.m index bc8c22bdd..276c6657d 100644 --- a/Riot/AppDelegate.m +++ b/Riot/AppDelegate.m @@ -2324,6 +2324,7 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN [homeViewController stopActivityIndicator]; roomPreviewData = [[RoomPreviewData alloc] initWithRoomId:roomIdOrAlias emailInvitationParams:queryParams andSession:account.mxSession]; + roomPreviewData.viaServers = queryParams[@"via"]; [self showRoomPreview:roomPreviewData]; } else @@ -2522,8 +2523,22 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN { 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; + } } } } diff --git a/Riot/Model/Room/RoomPreviewData.h b/Riot/Model/Room/RoomPreviewData.h index 333912c8f..47797327c 100644 --- a/Riot/Model/Room/RoomPreviewData.h +++ b/Riot/Model/Room/RoomPreviewData.h @@ -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 *viaServers; + /** Preview information. */ diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index 03e582aeb..30a754803 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -1815,8 +1815,9 @@ 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]; diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index c7c0818a8..ceafd6b03 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -1047,7 +1047,8 @@ // 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]; @@ -3685,7 +3686,7 @@ } // 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) {