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:
Stefan Ceriu
2026-10-15 15:24:35 +03:00
parent 626ea29868
commit 066e806c13
3 changed files with 7 additions and 13 deletions
@@ -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()
@@ -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()
}
}