mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add support for initiating and responding to user verification requests (#3759)
This commit is contained in:
@@ -278,7 +278,9 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
|
||||
let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationController,
|
||||
flow: .initiator)
|
||||
flow: .deviceInitiator,
|
||||
appSettings: appSettings,
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
let coordinator = SessionVerificationScreenCoordinator(parameters: parameters)
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import UserNotifications
|
||||
|
||||
enum RoomFlowCoordinatorAction: Equatable {
|
||||
case presentCallScreen(roomProxy: JoinedRoomProxyProtocol)
|
||||
case verifyUser(userID: String)
|
||||
case finished
|
||||
|
||||
static func == (lhs: RoomFlowCoordinatorAction, rhs: RoomFlowCoordinatorAction) -> Bool {
|
||||
@@ -1247,6 +1248,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
stateMachine.tryEvent(.startChildFlow(roomID: roomID, via: [], entryPoint: .room))
|
||||
case .startCall(let roomID):
|
||||
Task { await self.presentCallScreen(roomID: roomID) }
|
||||
case .verifyUser(let userID):
|
||||
actionsSubject.send(.verifyUser(userID: userID))
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
@@ -1272,6 +1275,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
stateMachine.tryEvent(.startChildFlow(roomID: roomID, via: [], entryPoint: .room))
|
||||
case .startCall(let roomID):
|
||||
Task { await self.presentCallScreen(roomID: roomID) }
|
||||
case .verifyUser(let userID):
|
||||
actionsSubject.send(.verifyUser(userID: userID))
|
||||
case .dismiss:
|
||||
break // Not supported when pushed.
|
||||
}
|
||||
@@ -1530,6 +1535,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
switch action {
|
||||
case .presentCallScreen(let roomProxy):
|
||||
actionsSubject.send(.presentCallScreen(roomProxy: roomProxy))
|
||||
case .verifyUser(let userID):
|
||||
actionsSubject.send(.verifyUser(userID: userID))
|
||||
case .finished:
|
||||
stateMachine.tryEvent(.dismissChildFlow)
|
||||
}
|
||||
|
||||
@@ -440,18 +440,26 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
MXLog.info("Received session verification request")
|
||||
|
||||
presentSessionVerificationScreen(details: details)
|
||||
if details.senderProfile.userID == userSession.clientProxy.userID {
|
||||
presentSessionVerificationScreen(flow: .deviceResponder(requestDetails: details))
|
||||
} else {
|
||||
presentSessionVerificationScreen(flow: .userResponder(requestDetails: details))
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
private func presentSessionVerificationScreen(details: SessionVerificationRequestDetails) {
|
||||
private func presentSessionVerificationScreen(flow: SessionVerificationScreenFlow) {
|
||||
guard let sessionVerificationController = userSession.clientProxy.sessionVerificationController else {
|
||||
fatalError("The sessionVerificationController should aways be valid at this point")
|
||||
}
|
||||
|
||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||
|
||||
let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationController,
|
||||
flow: .responder(details: details))
|
||||
flow: flow,
|
||||
appSettings: appSettings,
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
let coordinator = SessionVerificationScreenCoordinator(parameters: parameters)
|
||||
|
||||
@@ -464,7 +472,9 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
navigationSplitCoordinator.setSheetCoordinator(coordinator)
|
||||
navigationStackCoordinator.setRootCoordinator(coordinator)
|
||||
|
||||
navigationSplitCoordinator.setSheetCoordinator(navigationStackCoordinator)
|
||||
}
|
||||
|
||||
private func presentHomeScreen() {
|
||||
@@ -590,6 +600,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
case .presentCallScreen(let roomProxy):
|
||||
// Here we assume that the app is running and the call state is already up to date
|
||||
presentCallScreen(roomProxy: roomProxy, notifyOtherParticipants: !roomProxy.infoPublisher.value.hasRoomCall)
|
||||
case .verifyUser(let userID):
|
||||
presentSessionVerificationScreen(flow: .userIntiator(userID: userID))
|
||||
case .finished:
|
||||
stateMachine.processEvent(.deselectRoom)
|
||||
}
|
||||
@@ -911,6 +923,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
stateMachine.processEvent(.selectRoom(roomID: roomID, via: [], entryPoint: .room))
|
||||
case .startCall(let roomID):
|
||||
Task { await self.presentCallScreen(roomID: roomID, notifyOtherParticipants: false) }
|
||||
case .verifyUser(let userID):
|
||||
presentSessionVerificationScreen(flow: .userIntiator(userID: userID))
|
||||
case .dismiss:
|
||||
navigationSplitCoordinator.setSheetCoordinator(nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user