mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Base ElementCall encryption on the room encryption state, remove developer options setting
This commit is contained in:
committed by
Stefan Ceriu
parent
497177ee65
commit
7aa81f542c
@@ -231,9 +231,6 @@ final class AppSettings {
|
||||
@UserPreference(key: UserDefaultsKeys.elementCallBaseURL, defaultValue: "https://call.element.io", storageType: .userDefaults(store))
|
||||
var elementCallBaseURL: URL
|
||||
|
||||
@UserPreference(key: UserDefaultsKeys.elementCallEncryptionEnabled, defaultValue: true, storageType: .userDefaults(store))
|
||||
var elementCallUseEncryption
|
||||
|
||||
// MARK: - Notifications
|
||||
|
||||
@UserPreference(key: UserDefaultsKeys.enableNotifications, defaultValue: true, storageType: .userDefaults(store))
|
||||
|
||||
@@ -495,8 +495,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private func presentCallScreen(roomProxy: RoomProxyProtocol) {
|
||||
let callScreenCoordinator = CallScreenCoordinator(parameters: .init(roomProxy: roomProxy,
|
||||
callBaseURL: appSettings.elementCallBaseURL,
|
||||
clientID: InfoPlistReader.main.bundleIdentifier,
|
||||
useEncryption: appSettings.elementCallUseEncryption))
|
||||
clientID: InfoPlistReader.main.bundleIdentifier))
|
||||
|
||||
callScreenCoordinator.actions
|
||||
.sink { [weak self] action in
|
||||
|
||||
@@ -754,23 +754,23 @@ class ElementCallWidgetDriverMock: ElementCallWidgetDriverProtocol {
|
||||
|
||||
//MARK: - start
|
||||
|
||||
var startBaseURLClientIDUseEncryptionCallsCount = 0
|
||||
var startBaseURLClientIDUseEncryptionCalled: Bool {
|
||||
return startBaseURLClientIDUseEncryptionCallsCount > 0
|
||||
var startBaseURLClientIDCallsCount = 0
|
||||
var startBaseURLClientIDCalled: Bool {
|
||||
return startBaseURLClientIDCallsCount > 0
|
||||
}
|
||||
var startBaseURLClientIDUseEncryptionReceivedArguments: (baseURL: URL, clientID: String, useEncryption: Bool)?
|
||||
var startBaseURLClientIDUseEncryptionReceivedInvocations: [(baseURL: URL, clientID: String, useEncryption: Bool)] = []
|
||||
var startBaseURLClientIDUseEncryptionReturnValue: Result<URL, ElementCallWidgetDriverError>!
|
||||
var startBaseURLClientIDUseEncryptionClosure: ((URL, String, Bool) async -> Result<URL, ElementCallWidgetDriverError>)?
|
||||
var startBaseURLClientIDReceivedArguments: (baseURL: URL, clientID: String)?
|
||||
var startBaseURLClientIDReceivedInvocations: [(baseURL: URL, clientID: String)] = []
|
||||
var startBaseURLClientIDReturnValue: Result<URL, ElementCallWidgetDriverError>!
|
||||
var startBaseURLClientIDClosure: ((URL, String) async -> Result<URL, ElementCallWidgetDriverError>)?
|
||||
|
||||
func start(baseURL: URL, clientID: String, useEncryption: Bool) async -> Result<URL, ElementCallWidgetDriverError> {
|
||||
startBaseURLClientIDUseEncryptionCallsCount += 1
|
||||
startBaseURLClientIDUseEncryptionReceivedArguments = (baseURL: baseURL, clientID: clientID, useEncryption: useEncryption)
|
||||
startBaseURLClientIDUseEncryptionReceivedInvocations.append((baseURL: baseURL, clientID: clientID, useEncryption: useEncryption))
|
||||
if let startBaseURLClientIDUseEncryptionClosure = startBaseURLClientIDUseEncryptionClosure {
|
||||
return await startBaseURLClientIDUseEncryptionClosure(baseURL, clientID, useEncryption)
|
||||
func start(baseURL: URL, clientID: String) async -> Result<URL, ElementCallWidgetDriverError> {
|
||||
startBaseURLClientIDCallsCount += 1
|
||||
startBaseURLClientIDReceivedArguments = (baseURL: baseURL, clientID: clientID)
|
||||
startBaseURLClientIDReceivedInvocations.append((baseURL: baseURL, clientID: clientID))
|
||||
if let startBaseURLClientIDClosure = startBaseURLClientIDClosure {
|
||||
return await startBaseURLClientIDClosure(baseURL, clientID)
|
||||
} else {
|
||||
return startBaseURLClientIDUseEncryptionReturnValue
|
||||
return startBaseURLClientIDReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - sendMessage
|
||||
|
||||
@@ -96,7 +96,7 @@ extension RoomProxyMock {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
widgetDriver.startBaseURLClientIDUseEncryptionReturnValue = .success(url)
|
||||
widgetDriver.startBaseURLClientIDReturnValue = .success(url)
|
||||
|
||||
elementCallWidgetDriverReturnValue = widgetDriver
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ struct CallScreenCoordinatorParameters {
|
||||
let callBaseURL: URL
|
||||
/// A way to identify the current client against Element Call
|
||||
let clientID: String
|
||||
/// Whether encryption should be used within the call
|
||||
let useEncryption: Bool
|
||||
}
|
||||
|
||||
enum CallScreenCoordinatorAction {
|
||||
@@ -43,8 +41,7 @@ final class CallScreenCoordinator: CoordinatorProtocol {
|
||||
init(parameters: CallScreenCoordinatorParameters) {
|
||||
viewModel = CallScreenViewModel(roomProxy: parameters.roomProxy,
|
||||
callBaseURL: parameters.callBaseURL,
|
||||
clientID: parameters.clientID,
|
||||
useEncryption: parameters.useEncryption)
|
||||
clientID: parameters.clientID)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
||||
@@ -48,8 +48,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
|
||||
/// - clientID: Something to identify the current client on the Element Call side
|
||||
init(roomProxy: RoomProxyProtocol,
|
||||
callBaseURL: URL,
|
||||
clientID: String,
|
||||
useEncryption: Bool) {
|
||||
clientID: String) {
|
||||
self.roomProxy = roomProxy
|
||||
|
||||
widgetDriver = roomProxy.elementCallWidgetDriver()
|
||||
@@ -98,7 +97,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
|
||||
.store(in: &cancellables)
|
||||
|
||||
Task {
|
||||
switch await widgetDriver.start(baseURL: callBaseURL, clientID: clientID, useEncryption: useEncryption) {
|
||||
switch await widgetDriver.start(baseURL: callBaseURL, clientID: clientID) {
|
||||
case .success(let url):
|
||||
state.url = url
|
||||
case .failure(let error):
|
||||
|
||||
@@ -163,14 +163,13 @@ struct CallScreen_Previews: PreviewProvider {
|
||||
let widgetDriver = ElementCallWidgetDriverMock()
|
||||
widgetDriver.underlyingMessagePublisher = .init()
|
||||
widgetDriver.underlyingActions = PassthroughSubject<ElementCallWidgetDriverAction, Never>().eraseToAnyPublisher()
|
||||
widgetDriver.startBaseURLClientIDUseEncryptionReturnValue = .success(URL.userDirectory)
|
||||
widgetDriver.startBaseURLClientIDReturnValue = .success(URL.userDirectory)
|
||||
|
||||
roomProxy.elementCallWidgetDriverReturnValue = widgetDriver
|
||||
|
||||
return CallScreenViewModel(roomProxy: roomProxy,
|
||||
callBaseURL: "https://call.element.io",
|
||||
clientID: "io.element.elementx",
|
||||
useEncryption: false)
|
||||
clientID: "io.element.elementx")
|
||||
}()
|
||||
|
||||
static var previews: some View {
|
||||
|
||||
-1
@@ -53,7 +53,6 @@ protocol DeveloperOptionsProtocol: AnyObject {
|
||||
var roomListFiltersEnabled: Bool { get set }
|
||||
|
||||
var elementCallBaseURL: URL { get set }
|
||||
var elementCallUseEncryption: Bool { get set }
|
||||
}
|
||||
|
||||
extension AppSettings: DeveloperOptionsProtocol { }
|
||||
|
||||
-4
@@ -75,10 +75,6 @@ struct DeveloperOptionsScreen: View {
|
||||
.autocorrectionDisabled(true)
|
||||
.autocapitalization(.none)
|
||||
.foregroundColor(URL(string: elementCallBaseURLString) == nil ? .red : .primary)
|
||||
|
||||
Toggle(isOn: $context.elementCallUseEncryption) {
|
||||
Text("Use encryption")
|
||||
}
|
||||
}
|
||||
|
||||
Section {
|
||||
|
||||
@@ -52,11 +52,13 @@ class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriv
|
||||
self.room = room
|
||||
}
|
||||
|
||||
func start(baseURL: URL, clientID: String, useEncryption: Bool) async -> Result<URL, ElementCallWidgetDriverError> {
|
||||
func start(baseURL: URL, clientID: String) async -> Result<URL, ElementCallWidgetDriverError> {
|
||||
guard let room = room as? Room else {
|
||||
return .failure(.roomInvalid)
|
||||
}
|
||||
|
||||
let useEncryption = (try? room.isEncrypted()) ?? false
|
||||
|
||||
guard let widgetSettings = try? newVirtualElementCallWidget(props: .init(elementCallUrl: baseURL.absoluteString,
|
||||
widgetId: UUID().uuidString,
|
||||
parentUrl: nil,
|
||||
|
||||
@@ -35,7 +35,7 @@ protocol ElementCallWidgetDriverProtocol {
|
||||
var messagePublisher: PassthroughSubject<String, Never> { get }
|
||||
var actions: AnyPublisher<ElementCallWidgetDriverAction, Never> { get }
|
||||
|
||||
func start(baseURL: URL, clientID: String, useEncryption: Bool) async -> Result<URL, ElementCallWidgetDriverError>
|
||||
func start(baseURL: URL, clientID: String) async -> Result<URL, ElementCallWidgetDriverError>
|
||||
|
||||
func sendMessage(_ message: String) async -> Result<Bool, ElementCallWidgetDriverError>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user