matrix.to: Cannot open/preview a new room given by alias

#3991

Add a patch to try to build the right string and to avoid to loop forever
This commit is contained in:
manuroe
2021-02-02 17:07:12 +01:00
parent dfc17ced28
commit a2567cc1a0
2 changed files with 21 additions and 2 deletions
+20 -2
View File
@@ -1380,9 +1380,27 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
withString:[MXTools encodeURIComponent:roomId]
];
universalLinkFragmentPendingRoomAlias = @{roomId: roomIdOrAlias};
// 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])
{
newUniversalLinkFragment =
[fragment stringByReplacingOccurrencesOfString:roomIdOrAlias
withString:[MXTools encodeURIComponent:roomId]];
}
[self handleUniversalLinkFragment:newUniversalLinkFragment];
if (![newUniversalLinkFragment isEqualToString:fragment])
{
universalLinkFragmentPendingRoomAlias = @{roomId: roomIdOrAlias};
[self handleUniversalLinkFragment:newUniversalLinkFragment];
}
else
{
// Do not continue. Else we will loop forever
NSLog(@"[AppDelegate] Universal link: Error: Cannot resolve alias in %@ to the room id %@", fragment, roomId);
}
}
} failure:^(NSError *error) {