mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-19 16:13:42 +02:00
Show confirmation alert if given and visible urls different, when tapped a link in a message cell, fixes #3137
This commit is contained in:
@@ -3143,6 +3143,45 @@
|
||||
shouldDoAction = NO;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
MXEvent *tappedEvent = userInfo[kMXKRoomBubbleCellEventKey];
|
||||
NSString *format = tappedEvent.content[@"format"];
|
||||
NSString *formattedBody = tappedEvent.content[@"formatted_body"];
|
||||
// if an html formatted body exists
|
||||
if ([format isEqualToString:kMXRoomMessageFormatHTML] && formattedBody)
|
||||
{
|
||||
FormattedBodyParser *parser = [[FormattedBodyParser alloc] initWithFormattedBody:formattedBody];
|
||||
NSURL *visibleURL = [parser getVisibleURLForURL:url];
|
||||
|
||||
if (visibleURL && ![url isEqual:visibleURL])
|
||||
{
|
||||
// urls are different, show confirmation alert
|
||||
NSString *formatStr = NSLocalizedStringFromTable(@"external_link_confirmation_message", @"Vector", nil);
|
||||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"external_link_confirmation_title", @"Vector", nil) message:[NSString stringWithFormat:formatStr, visibleURL.absoluteString, url.absoluteString] preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
UIAlertAction *continueAction = [UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"continue", @"Vector", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
||||
// Try to open the link
|
||||
[[UIApplication sharedApplication] vc_open:url completionHandler:^(BOOL success) {
|
||||
if (!success)
|
||||
{
|
||||
[self showUnableToOpenLinkErrorAlert];
|
||||
}
|
||||
}];
|
||||
}];
|
||||
|
||||
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"cancel", @"Vector", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
||||
// no-op
|
||||
}];
|
||||
|
||||
[alert addAction:continueAction];
|
||||
[alert addAction:cancelAction];
|
||||
|
||||
[self presentViewController:alert animated:YES completion:^{
|
||||
// no-op
|
||||
}];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
// Try to open the link
|
||||
[[UIApplication sharedApplication] vc_open:url completionHandler:^(BOOL success) {
|
||||
if (!success)
|
||||
@@ -3152,6 +3191,7 @@
|
||||
}];
|
||||
shouldDoAction = NO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user