mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-23 18:12:44 +02:00
Merge branch 'develop' into voip_2746
This commit is contained in:
@@ -244,7 +244,8 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
// Redirect NSLogs to files only if we are not debugging
|
||||
if (!isatty(STDERR_FILENO))
|
||||
{
|
||||
[MXLogger redirectNSLogToFiles:YES numberOfFiles:50];
|
||||
NSUInteger sizeLimit = 100 * 1024 * 1024; // 100MB
|
||||
[MXLogger redirectNSLogToFiles:YES numberOfFiles:50 sizeLimit:sizeLimit];
|
||||
}
|
||||
|
||||
NSLog(@"[AppDelegate] initialize: Done");
|
||||
@@ -1138,9 +1139,9 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:AppDelegateUniversalLinkDidChangeNotification object:nil];
|
||||
}
|
||||
|
||||
if ([webURL.path isEqualToString:@"/"])
|
||||
if ([self handleServerProvionningLink:webURL])
|
||||
{
|
||||
return [self handleServerProvionningLink:webURL];
|
||||
return YES;
|
||||
}
|
||||
|
||||
NSString *validateEmailSubmitTokenPath = @"validate/email/submitToken";
|
||||
@@ -1247,6 +1248,10 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
|
||||
NSLog(@"[AppDelegate] Universal link: handleUniversalLinkFragment: %@", fragment);
|
||||
|
||||
// Make sure we have plain utf8 character for separators
|
||||
fragment = [fragment stringByRemovingPercentEncoding];
|
||||
NSLog(@"[AppDelegate] Universal link: handleUniversalLinkFragment: %@", fragment);
|
||||
|
||||
// The app manages only one universal link at a time
|
||||
// Discard any pending one
|
||||
[self resetPendingUniversalLink];
|
||||
@@ -1368,9 +1373,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) {
|
||||
@@ -1414,40 +1437,32 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
// FIXME: In case of multi-account, ask the user which one to use
|
||||
MXKAccount* account = accountManager.activeAccounts.firstObject;
|
||||
|
||||
RoomPreviewData *roomPreviewData;
|
||||
RoomPreviewData *roomPreviewData = [[RoomPreviewData alloc] initWithRoomId:roomIdOrAlias
|
||||
andSession:account.mxSession];
|
||||
if (queryParams)
|
||||
{
|
||||
roomPreviewData.viaServers = queryParams[@"via"];
|
||||
}
|
||||
|
||||
// Is it a link to an event of a room?
|
||||
// If yes, the event will be displayed once the room is joined
|
||||
roomPreviewData.eventId = (pathParams.count >= 3) ? pathParams[2] : nil;
|
||||
|
||||
// Try to get more information about the room before opening its preview
|
||||
[roomPreviewData peekInRoom:^(BOOL succeeded) {
|
||||
|
||||
// Note: the activity indicator will not disappear if the session is not ready
|
||||
[homeViewController stopActivityIndicator];
|
||||
|
||||
roomPreviewData = [[RoomPreviewData alloc] initWithRoomId:roomIdOrAlias emailInvitationParams:queryParams andSession:account.mxSession];
|
||||
roomPreviewData.viaServers = queryParams[@"via"];
|
||||
// If no data is available for this room, we name it with the known room alias (if any).
|
||||
if (!succeeded && universalLinkFragmentPendingRoomAlias[roomIdOrAlias])
|
||||
{
|
||||
roomPreviewData.roomName = universalLinkFragmentPendingRoomAlias[roomIdOrAlias];
|
||||
}
|
||||
universalLinkFragmentPendingRoomAlias = nil;
|
||||
|
||||
[self showRoomPreview:roomPreviewData];
|
||||
}
|
||||
else
|
||||
{
|
||||
roomPreviewData = [[RoomPreviewData alloc] initWithRoomId:roomIdOrAlias andSession:account.mxSession];
|
||||
|
||||
// Is it a link to an event of a room?
|
||||
// If yes, the event will be displayed once the room is joined
|
||||
roomPreviewData.eventId = (pathParams.count >= 3) ? pathParams[2] : nil;
|
||||
|
||||
// Try to get more information about the room before opening its preview
|
||||
[roomPreviewData peekInRoom:^(BOOL succeeded) {
|
||||
|
||||
// Note: the activity indicator will not disappear if the session is not ready
|
||||
[homeViewController stopActivityIndicator];
|
||||
|
||||
// If no data is available for this room, we name it with the known room alias (if any).
|
||||
if (!succeeded && universalLinkFragmentPendingRoomAlias[roomIdOrAlias])
|
||||
{
|
||||
roomPreviewData.roomName = universalLinkFragmentPendingRoomAlias[roomIdOrAlias];
|
||||
}
|
||||
universalLinkFragmentPendingRoomAlias = nil;
|
||||
|
||||
[self showRoomPreview:roomPreviewData];
|
||||
}];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2218,6 +2233,11 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
case MXSessionStateSyncInProgress:
|
||||
// Stay in launching during the first server sync if the store is empty.
|
||||
isLaunching = (mainSession.rooms.count == 0 && launchAnimationContainerView);
|
||||
|
||||
if (mainSession.crypto.crossSigning && mainSession.crypto.crossSigning.state == MXCrossSigningStateCrossSigningExists)
|
||||
{
|
||||
[mainSession.crypto setOutgoingKeyRequestsEnabled:NO onComplete:nil];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
isLaunching = NO;
|
||||
@@ -3486,81 +3506,100 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
return;
|
||||
}
|
||||
|
||||
MXWeakify(self);
|
||||
[mxSession.crypto pendingKeyRequests:^(MXUsersDevicesMap<NSArray<MXIncomingRoomKeyRequest *> *> *pendingKeyRequests) {
|
||||
|
||||
NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: pendingKeyRequests.count: %@. Already displayed: %@",
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: cross-signing state: %ld, pendingKeyRequests.count: %@. Already displayed: %@",
|
||||
mxSession.crypto.crossSigning.state,
|
||||
@(pendingKeyRequests.count),
|
||||
roomKeyRequestViewController ? @"YES" : @"NO");
|
||||
self->roomKeyRequestViewController ? @"YES" : @"NO");
|
||||
|
||||
if (roomKeyRequestViewController)
|
||||
if (!mxSession.crypto.crossSigning || mxSession.crypto.crossSigning.state == MXCrossSigningStateNotBootstrapped)
|
||||
{
|
||||
// Check if the current RoomKeyRequestViewController is still valid
|
||||
MXSession *currentMXSession = roomKeyRequestViewController.mxSession;
|
||||
NSString *currentUser = roomKeyRequestViewController.device.userId;
|
||||
NSString *currentDevice = roomKeyRequestViewController.device.deviceId;
|
||||
|
||||
NSArray<MXIncomingRoomKeyRequest *> *currentPendingRequest = [pendingKeyRequests objectForDevice:currentDevice forUser:currentUser];
|
||||
|
||||
if (currentMXSession == mxSession && currentPendingRequest.count == 0)
|
||||
if (self->roomKeyRequestViewController)
|
||||
{
|
||||
NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Cancel current dialog");
|
||||
// Check if the current RoomKeyRequestViewController is still valid
|
||||
MXSession *currentMXSession = self->roomKeyRequestViewController.mxSession;
|
||||
NSString *currentUser = self->roomKeyRequestViewController.device.userId;
|
||||
NSString *currentDevice = self->roomKeyRequestViewController.device.deviceId;
|
||||
|
||||
// The key request has been probably cancelled, remove the popup
|
||||
[roomKeyRequestViewController hide];
|
||||
roomKeyRequestViewController = nil;
|
||||
NSArray<MXIncomingRoomKeyRequest *> *currentPendingRequest = [pendingKeyRequests objectForDevice:currentDevice forUser:currentUser];
|
||||
|
||||
if (currentMXSession == mxSession && currentPendingRequest.count == 0)
|
||||
{
|
||||
NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Cancel current dialog");
|
||||
|
||||
// The key request has been probably cancelled, remove the popup
|
||||
[self->roomKeyRequestViewController hide];
|
||||
self->roomKeyRequestViewController = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!roomKeyRequestViewController && pendingKeyRequests.count)
|
||||
if (!self->roomKeyRequestViewController && pendingKeyRequests.count)
|
||||
{
|
||||
// Pick the first coming user/device pair
|
||||
NSString *userId = pendingKeyRequests.userIds.firstObject;
|
||||
NSString *deviceId = [pendingKeyRequests deviceIdsForUser:userId].firstObject;
|
||||
|
||||
|
||||
// Give the client a chance to refresh the device list
|
||||
MXWeakify(self);
|
||||
[mxSession.crypto downloadKeys:@[userId] forceDownload:NO success:^(MXUsersDevicesMap<MXDeviceInfo *> *usersDevicesInfoMap, NSDictionary<NSString *,MXCrossSigningInfo *> *crossSigningKeysMap) {
|
||||
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
MXDeviceInfo *deviceInfo = [usersDevicesInfoMap objectForDevice:deviceId forUser:userId];
|
||||
if (deviceInfo)
|
||||
{
|
||||
BOOL wasNewDevice = (deviceInfo.trustLevel.localVerificationStatus == MXDeviceUnknown);
|
||||
|
||||
void (^openDialog)(void) = ^void()
|
||||
if (!mxSession.crypto.crossSigning || mxSession.crypto.crossSigning.state == MXCrossSigningStateNotBootstrapped)
|
||||
{
|
||||
NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Open dialog for %@", deviceInfo);
|
||||
BOOL wasNewDevice = (deviceInfo.trustLevel.localVerificationStatus == MXDeviceUnknown);
|
||||
|
||||
void (^openDialog)(void) = ^void()
|
||||
{
|
||||
NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Open dialog for %@", deviceInfo);
|
||||
|
||||
roomKeyRequestViewController = [[RoomKeyRequestViewController alloc] initWithDeviceInfo:deviceInfo wasNewDevice:wasNewDevice andMatrixSession:mxSession onComplete:^{
|
||||
self->roomKeyRequestViewController = [[RoomKeyRequestViewController alloc] initWithDeviceInfo:deviceInfo wasNewDevice:wasNewDevice andMatrixSession:mxSession onComplete:^{
|
||||
|
||||
roomKeyRequestViewController = nil;
|
||||
self->roomKeyRequestViewController = nil;
|
||||
|
||||
// Check next pending key request, if any
|
||||
// Check next pending key request, if any
|
||||
[self checkPendingRoomKeyRequests];
|
||||
}];
|
||||
|
||||
[self->roomKeyRequestViewController show];
|
||||
};
|
||||
|
||||
// If the device was new before, it's not any more.
|
||||
if (wasNewDevice)
|
||||
{
|
||||
[mxSession.crypto setDeviceVerification:MXDeviceUnverified forDevice:deviceId ofUser:userId success:openDialog failure:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
openDialog();
|
||||
}
|
||||
}
|
||||
else if (deviceInfo.trustLevel.isVerified)
|
||||
{
|
||||
[mxSession.crypto acceptAllPendingKeyRequestsFromUser:userId andDevice:deviceId onComplete:^{
|
||||
[self checkPendingRoomKeyRequests];
|
||||
}];
|
||||
|
||||
[roomKeyRequestViewController show];
|
||||
};
|
||||
|
||||
// If the device was new before, it's not any more.
|
||||
if (wasNewDevice)
|
||||
{
|
||||
[mxSession.crypto setDeviceVerification:MXDeviceUnverified forDevice:deviceId ofUser:userId success:openDialog failure:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
openDialog();
|
||||
[mxSession.crypto ignoreAllPendingKeyRequestsFromUser:userId andDevice:deviceId onComplete:^{
|
||||
[self checkPendingRoomKeyRequests];
|
||||
}];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: No details found for device %@:%@", userId, deviceId);
|
||||
|
||||
// Ignore this device to avoid to loop on it
|
||||
[mxSession.crypto ignoreAllPendingKeyRequestsFromUser:userId andDevice:deviceId onComplete:^{
|
||||
// And check next requests
|
||||
[self checkPendingRoomKeyRequests];
|
||||
}];
|
||||
}
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
// Retry later
|
||||
NSLog(@"[AppDelegate] checkPendingRoomKeyRequestsInSession: Failed to download device keys. Retry");
|
||||
@@ -3732,6 +3771,12 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
|
||||
- (void)keyVerificationCoordinatorBridgePresenterDelegateDidComplete:(KeyVerificationCoordinatorBridgePresenter *)coordinatorBridgePresenter otherUserId:(NSString * _Nonnull)otherUserId otherDeviceId:(NSString * _Nonnull)otherDeviceId
|
||||
{
|
||||
MXCrypto *crypto = coordinatorBridgePresenter.session.crypto;
|
||||
if (!crypto.backup.hasPrivateKeyInCryptoStore || !crypto.backup.enabled)
|
||||
{
|
||||
NSLog(@"[AppDelegate][MXKeyVerification] requestAllPrivateKeys: Request key backup private keys");
|
||||
[crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil];
|
||||
}
|
||||
[self dismissKeyVerificationCoordinatorBridgePresenter];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user