mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-05 23:47:44 +02:00
Merge pull request #5937 from vector-im/andy/4858_resolve_alias
Enable joining a room via identifier from another home server
This commit is contained in:
@@ -1487,7 +1487,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
// Ask the HS to resolve the room alias into a room id and then retry
|
||||
self->universalLinkFragmentPending = fragment;
|
||||
MXKAccount* account = accountManager.activeAccounts.firstObject;
|
||||
[account.mxSession.matrixRestClient roomIDForRoomAlias:roomIdOrAlias success:^(NSString *roomId) {
|
||||
[account.mxSession.matrixRestClient resolveRoomAlias:roomIdOrAlias success:^(MXRoomAliasResolution *resolution) {
|
||||
|
||||
// Note: the activity indicator will not disappear if the session is not ready
|
||||
[homeViewController stopActivityIndicator];
|
||||
@@ -1495,34 +1495,20 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
// Check that 'fragment' has not been cancelled
|
||||
if ([self->universalLinkFragmentPending isEqualToString:fragment])
|
||||
{
|
||||
// Retry opening the link but with the returned room id
|
||||
NSString *newUniversalLinkFragment =
|
||||
[fragment stringByReplacingOccurrencesOfString:[MXTools encodeURIComponent:roomIdOrAlias]
|
||||
withString:[MXTools encodeURIComponent:roomId]
|
||||
];
|
||||
|
||||
// The previous operation can fail because of percent encoding
|
||||
// TBH we are not clean on data inputs. For the moment, just give another try with no encoding
|
||||
// TODO: Have a dedicated module and tests to handle universal links (matrix.to, email link, etc)
|
||||
if ([newUniversalLinkFragment isEqualToString:fragment])
|
||||
NSString *newFragment = resolution.deeplinkFragment;
|
||||
if (newFragment && ![newFragment isEqualToString:fragment])
|
||||
{
|
||||
newUniversalLinkFragment =
|
||||
[fragment stringByReplacingOccurrencesOfString:roomIdOrAlias
|
||||
withString:[MXTools encodeURIComponent:roomId]];
|
||||
}
|
||||
|
||||
if (![newUniversalLinkFragment isEqualToString:fragment])
|
||||
{
|
||||
self->universalLinkFragmentPendingRoomAlias = @{roomId: roomIdOrAlias};
|
||||
|
||||
UniversalLinkParameters *newParameters = [[UniversalLinkParameters alloc] initWithFragment:newUniversalLinkFragment universalLinkURL:universalLinkURL presentationParameters:presentationParameters];
|
||||
|
||||
self->universalLinkFragmentPendingRoomAlias = @{resolution.roomId: roomIdOrAlias};
|
||||
|
||||
UniversalLinkParameters *newParameters = [[UniversalLinkParameters alloc] initWithFragment:newFragment
|
||||
universalLinkURL:universalLinkURL
|
||||
presentationParameters:presentationParameters];
|
||||
[self handleUniversalLinkWithParameters:newParameters];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do not continue. Else we will loop forever
|
||||
MXLogDebug(@"[AppDelegate] Universal link: Error: Cannot resolve alias in %@ to the room id %@", fragment, roomId);
|
||||
MXLogDebug(@"[AppDelegate] Universal link: Error: Cannot resolve alias in %@ to the room id %@", fragment, resolution.roomId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user