Merge pull request #2557 from vector-im/riot_2547

Join Room: Support via parameters to better handle federation
This commit is contained in:
manuroe 2019-07-08 14:53:02 +02:00 committed by GitHub
commit 138d03d5b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 7 deletions

View file

@ -4,6 +4,8 @@ Changes in 0.8.7 (2019-xx-xx)
Improvements:
* RoomVC: When replying, use a "Reply" button instead of "Send".
* RoomVC: New message actions (#2394).
* Room upgrade: Use the `server_name` parameter when joining the new room (#2550).
* 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).

View file

@ -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
@ -2523,10 +2524,24 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
value = [value stringByReplacingOccurrencesOfString:@"+" withString:@" "];
value = [value stringByRemovingPercentEncoding];
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;
}
}
}
}
*outPathParams = pathParams;
*outQueryParams = queryParams;

View file

@ -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.
*/

View file

@ -1816,7 +1816,8 @@
[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];

View file

@ -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)
{
@ -4047,8 +4048,15 @@
}
else if (customizedRoomDataSource.roomState.isObsolete)
{
// Try to join via the server that sent the event
MXEvent *stoneTombEvent = [customizedRoomDataSource.roomState stateEventsWithType:kMXEventTypeStringRoomTombStone].lastObject;
NSString *viaSenderServer = [MXTools serverNameInMatrixIdentifier:stoneTombEvent.sender];
NSString *replacementRoomId = customizedRoomDataSource.roomState.tombStoneContent.replacementRoomId;
NSString *roomLinkFragment = [NSString stringWithFormat:@"/room/%@", [MXTools encodeURIComponent:replacementRoomId]];
NSString *roomLinkFragment = [NSString stringWithFormat:@"/room/%@?via=%@",
[MXTools encodeURIComponent:replacementRoomId],
viaSenderServer
];
[roomActivitiesView displayRoomReplacementWithRoomLinkTappedHandler:^{
[[AppDelegate theDelegate] handleUniversalLinkFragment:roomLinkFragment];