mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-26 11:39:00 +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)
|
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()
|
startSasVerification()
|
||||||
case (.showingChallenge, .acceptChallenge, .acceptingChallenge):
|
case (.showingChallenge, .acceptChallenge, .acceptingChallenge):
|
||||||
acceptChallenge()
|
acceptChallenge()
|
||||||
|
|||||||
+4
-4
@@ -200,10 +200,10 @@ class SessionVerificationControllerProxy: SessionVerificationControllerProxyProt
|
|||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func didAcceptVerificationRequest() {
|
fileprivate func didAcceptVerificationRequest() {
|
||||||
// Noop because the rust side state machine changes states before sending
|
// Only called when the other device accepted our request. Accepting an incoming one is
|
||||||
// the actual request, leading to race conditions with the SAS verification
|
// reported from the `acceptVerificationRequest` method above.
|
||||||
// startup. The `acceptedVerificationRequest` is now called from the `startSasVerification`
|
MXLog.info("Verification request accepted by the other device")
|
||||||
// method above.
|
actions.send(.acceptedVerificationRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func didStartSasVerification() {
|
fileprivate func didStartSasVerification() {
|
||||||
|
|||||||
@@ -111,12 +111,6 @@ struct SessionVerificationViewModelTests {
|
|||||||
|
|
||||||
private mutating func setupChallengeReceived() async throws {
|
private mutating func setupChallengeReceived() async throws {
|
||||||
let actionsPublisher = sessionVerificationController.actions.delay(for: .seconds(0.1), scheduler: DispatchQueue.main)
|
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,
|
let deferred = deferFulfillment(actionsPublisher,
|
||||||
keyPath: \.self,
|
keyPath: \.self,
|
||||||
@@ -129,7 +123,5 @@ struct SessionVerificationViewModelTests {
|
|||||||
#expect(context.viewState.verificationState == .showingChallenge(emojis: SessionVerificationControllerProxyMock.emojis))
|
#expect(context.viewState.verificationState == .showingChallenge(emojis: SessionVerificationControllerProxyMock.emojis))
|
||||||
#expect(sessionVerificationController.requestDeviceVerificationCallsCount == 1)
|
#expect(sessionVerificationController.requestDeviceVerificationCallsCount == 1)
|
||||||
#expect(sessionVerificationController.startSasVerificationCallsCount == 1)
|
#expect(sessionVerificationController.startSasVerificationCallsCount == 1)
|
||||||
|
|
||||||
cancellable.cancel()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user