mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-24 18:59:36 +00:00
Start the SAS verification when the other device accepts our request
Element X Android doesn't start SAS after accepting a request, so iOS requests to it never progressed. Either side may start per the spec and the SDK resolves the conflict if both do. Requires the SDK change making `didAcceptVerificationRequest` fire only on the requesting side.
This commit is contained in:
+3
-1
@@ -130,7 +130,9 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
|
||||
self.stateMachine.processEvent(.didFail)
|
||||
}
|
||||
}
|
||||
case (.acceptingVerificationRequest, .didAcceptVerificationRequest, .verificationRequestAccepted):
|
||||
case (.acceptingVerificationRequest, .didAcceptVerificationRequest, .verificationRequestAccepted),
|
||||
(.requestingVerification, .didAcceptVerificationRequest, .verificationRequestAccepted):
|
||||
// Either side may start the SAS verification, the SDK resolves the conflict if both do.
|
||||
startSasVerification()
|
||||
case (.showingChallenge, .acceptChallenge, .acceptingChallenge):
|
||||
acceptChallenge()
|
||||
|
||||
+4
-4
@@ -200,10 +200,10 @@ class SessionVerificationControllerProxy: SessionVerificationControllerProxyProt
|
||||
}
|
||||
|
||||
fileprivate func didAcceptVerificationRequest() {
|
||||
// Noop because the rust side state machine changes states before sending
|
||||
// the actual request, leading to race conditions with the SAS verification
|
||||
// startup. The `acceptedVerificationRequest` is now called from the `startSasVerification`
|
||||
// method above.
|
||||
// Only called when the other device accepted our request. Accepting an incoming one is
|
||||
// reported from the `acceptVerificationRequest` method above.
|
||||
MXLog.info("Verification request accepted by the other device")
|
||||
actions.send(.acceptedVerificationRequest)
|
||||
}
|
||||
|
||||
fileprivate func didStartSasVerification() {
|
||||
|
||||
@@ -111,12 +111,6 @@ struct SessionVerificationViewModelTests {
|
||||
|
||||
private mutating func setupChallengeReceived() async throws {
|
||||
let actionsPublisher = sessionVerificationController.actions.delay(for: .seconds(0.1), scheduler: DispatchQueue.main)
|
||||
let cancellable = actionsPublisher
|
||||
.sink { [sessionVerificationController] action in
|
||||
if case .acceptedVerificationRequest = action {
|
||||
Task { await sessionVerificationController?.startSasVerification() }
|
||||
}
|
||||
}
|
||||
|
||||
let deferred = deferFulfillment(actionsPublisher,
|
||||
keyPath: \.self,
|
||||
@@ -129,7 +123,5 @@ struct SessionVerificationViewModelTests {
|
||||
#expect(context.viewState.verificationState == .showingChallenge(emojis: SessionVerificationControllerProxyMock.emojis))
|
||||
#expect(sessionVerificationController.requestDeviceVerificationCallsCount == 1)
|
||||
#expect(sessionVerificationController.startSasVerificationCallsCount == 1)
|
||||
|
||||
cancellable.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user