mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Merge pull request #4220 from vector-im/manu/4217_verification_as_per_web
Self-verification: Fix compatibility with Element-Web
This commit is contained in:
commit
f0ba3e91a3
3 changed files with 51 additions and 17 deletions
|
@ -8,7 +8,7 @@ Changes to be released in next version
|
|||
*
|
||||
|
||||
🐛 Bugfix
|
||||
*
|
||||
* Self-verification: Fix compatibility with Element-Web (#4217).
|
||||
|
||||
⚠️ API Changes
|
||||
*
|
||||
|
|
|
@ -2274,21 +2274,29 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
|||
|
||||
if (mainSession.crypto.crossSigning)
|
||||
{
|
||||
NSLog(@"[AppDelegate] handleAppState: crossSigning.state: %@", @(mainSession.crypto.crossSigning.state));
|
||||
|
||||
switch (mainSession.crypto.crossSigning.state)
|
||||
{
|
||||
case MXCrossSigningStateCrossSigningExists:
|
||||
NSLog(@"[AppDelegate] handleAppState: presentVerifyCurrentSessionAlertIfNeededWithSession");
|
||||
[_masterTabBarController presentVerifyCurrentSessionAlertIfNeededWithSession:mainSession];
|
||||
break;
|
||||
case MXCrossSigningStateCanCrossSign:
|
||||
NSLog(@"[AppDelegate] handleAppState: presentReviewUnverifiedSessionsAlertIfNeededWithSession");
|
||||
[_masterTabBarController presentReviewUnverifiedSessionsAlertIfNeededWithSession:mainSession];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// Get the up-to-date cross-signing state
|
||||
MXWeakify(self);
|
||||
[mainSession.crypto.crossSigning refreshStateWithSuccess:^(BOOL stateUpdated) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
|
||||
NSLog(@"[AppDelegate] handleAppState: crossSigning.state: %@", @(mainSession.crypto.crossSigning.state));
|
||||
|
||||
switch (mainSession.crypto.crossSigning.state)
|
||||
{
|
||||
case MXCrossSigningStateCrossSigningExists:
|
||||
NSLog(@"[AppDelegate] handleAppState: presentVerifyCurrentSessionAlertIfNeededWithSession");
|
||||
[self.masterTabBarController presentVerifyCurrentSessionAlertIfNeededWithSession:mainSession];
|
||||
break;
|
||||
case MXCrossSigningStateCanCrossSign:
|
||||
NSLog(@"[AppDelegate] handleAppState: presentReviewUnverifiedSessionsAlertIfNeededWithSession");
|
||||
[self.masterTabBarController presentReviewUnverifiedSessionsAlertIfNeededWithSession:mainSession];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} failure:^(NSError * _Nonnull error) {
|
||||
NSLog(@"[AppDelegate] handleAppState: crossSigning.state: %@. Error: %@", @(mainSession.crypto.crossSigning.state), error);
|
||||
}];
|
||||
}
|
||||
|
||||
// TODO: We should wait that cross-signing screens are done before going further but it seems fine. Those screens
|
||||
|
@ -3934,6 +3942,18 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
|||
[self.incomingKeyVerificationRequestAlertController dismissViewControllerAnimated:NO completion:nil];
|
||||
}
|
||||
|
||||
if (self.userNewSignInAlertController
|
||||
&& [session.myUserId isEqualToString:senderId])
|
||||
{
|
||||
// If it is a self verification for my device, we can discard the new signin alert.
|
||||
// Note: It will not work well with several devices to verify at the same time.
|
||||
NSLog(@"[AppDelegate] presentNewKeyVerificationRequest: Remove the alert for new sign in detected");
|
||||
[self.userNewSignInAlertController dismissViewControllerAnimated:NO completion:^{
|
||||
self.userNewSignInAlertController = nil;
|
||||
[self presentNewKeyVerificationRequestAlertForSession:session senderName:senderName senderId:senderId request:keyVerificationRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
NSString *senderInfo;
|
||||
|
||||
if (senderName)
|
||||
|
@ -3955,7 +3975,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"key_verification_tile_request_incoming_title", @"Vector", nil)
|
||||
message:senderInfo
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
|
|
@ -91,6 +91,21 @@ final class KeyVerificationSelfVerifyWaitViewModel: KeyVerificationSelfVerifyWai
|
|||
} else {
|
||||
// be sure that session has completed its first sync
|
||||
if session.state >= MXSessionStateRunning {
|
||||
|
||||
// Always send request instead of waiting for an incoming one as per recent EW changes
|
||||
print("[KeyVerificationSelfVerifyWaitViewModel] loadData: Send a verification request to all devices instead of waiting")
|
||||
|
||||
let keyVerificationService = KeyVerificationService()
|
||||
self.verificationManager.requestVerificationByToDevice(withUserId: self.session.myUserId, deviceIds: nil, methods: keyVerificationService.supportedKeyVerificationMethods(), success: { [weak self] (keyVerificationRequest) in
|
||||
guard let self = self else {
|
||||
return
|
||||
}
|
||||
|
||||
self.keyVerificationRequest = keyVerificationRequest
|
||||
|
||||
}, failure: { [weak self] error in
|
||||
self?.update(viewState: .error(error))
|
||||
})
|
||||
continueLoadData()
|
||||
} else {
|
||||
// show loader
|
||||
|
|
Loading…
Reference in a new issue