mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
disable creation and enabling of e2ee if remote preference for disabling it is true
This commit is contained in:
@@ -24,6 +24,7 @@ nonisolated protocol CommonSettingsProtocol: AnyObject, Sendable {
|
|||||||
var traceLogPacks: Set<TraceLogPack> { get }
|
var traceLogPacks: Set<TraceLogPack> { get }
|
||||||
var bugReportRageshakeURL: RemotePreference<RageshakeConfiguration> { get }
|
var bugReportRageshakeURL: RemotePreference<RageshakeConfiguration> { get }
|
||||||
var contentScannerURL: RemotePreference<URL?> { get }
|
var contentScannerURL: RemotePreference<URL?> { get }
|
||||||
|
var forceDisableE2EE: RemotePreference<Bool> { get }
|
||||||
|
|
||||||
var enableOnlySignedDeviceIsolationMode: Bool { get }
|
var enableOnlySignedDeviceIsolationMode: Bool { get }
|
||||||
var threadsEnabled: Bool { get }
|
var threadsEnabled: Bool { get }
|
||||||
@@ -272,6 +273,12 @@ final nonisolated class AppSettings: @unchecked Sendable {
|
|||||||
/// `nil` when content scanning is disabled.
|
/// `nil` when content scanning is disabled.
|
||||||
let contentScannerURL: RemotePreference<URL?> = .init(nil)
|
let contentScannerURL: RemotePreference<URL?> = .init(nil)
|
||||||
|
|
||||||
|
// MARK: - Encryption
|
||||||
|
|
||||||
|
/// Whether the server forbids the use of E2EE: new rooms are created unencrypted and
|
||||||
|
/// enabling encryption on existing rooms is not offered.
|
||||||
|
let forceDisableE2EE: RemotePreference<Bool> = .init(false)
|
||||||
|
|
||||||
// MARK: - Analytics
|
// MARK: - Analytics
|
||||||
|
|
||||||
/// The configuration to use for analytics. Set to `nil` to disable analytics.
|
/// The configuration to use for analytics. Set to `nil` to disable analytics.
|
||||||
|
|||||||
+1
-1
@@ -161,7 +161,7 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType,
|
|||||||
state.canEditAddress = powerLevels.canOwnUser(sendStateEvent: .roomCanonicalAlias)
|
state.canEditAddress = powerLevels.canOwnUser(sendStateEvent: .roomCanonicalAlias)
|
||||||
state.canEditJoinRule = powerLevels.canOwnUser(sendStateEvent: .roomJoinRules)
|
state.canEditJoinRule = powerLevels.canOwnUser(sendStateEvent: .roomJoinRules)
|
||||||
state.canEditHistoryVisibility = powerLevels.canOwnUser(sendStateEvent: .roomHistoryVisibility)
|
state.canEditHistoryVisibility = powerLevels.canOwnUser(sendStateEvent: .roomHistoryVisibility)
|
||||||
state.canEnableEncryption = powerLevels.canOwnUser(sendStateEvent: .roomEncryption)
|
state.canEnableEncryption = powerLevels.canOwnUser(sendStateEvent: .roomEncryption) && !appSettings.forceDisableE2EE.publisher.value
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setupRoomDirectoryVisibility() {
|
private func setupRoomDirectoryVisibility() {
|
||||||
|
|||||||
@@ -482,7 +482,7 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
do {
|
do {
|
||||||
let parameters = CreateRoomParameters(name: nil,
|
let parameters = CreateRoomParameters(name: nil,
|
||||||
topic: nil,
|
topic: nil,
|
||||||
isEncrypted: true,
|
isEncrypted: !appSettings.forceDisableE2EE.publisher.value,
|
||||||
isDirect: true,
|
isDirect: true,
|
||||||
visibility: .private,
|
visibility: .private,
|
||||||
preset: .trustedPrivateChat,
|
preset: .trustedPrivateChat,
|
||||||
@@ -525,7 +525,7 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
|
|
||||||
let parameters = CreateRoomParameters(name: name,
|
let parameters = CreateRoomParameters(name: name,
|
||||||
topic: topic,
|
topic: topic,
|
||||||
isEncrypted: accessType.isEncrypted,
|
isEncrypted: !appSettings.forceDisableE2EE.publisher.value && accessType.isEncrypted,
|
||||||
isDirect: false,
|
isDirect: false,
|
||||||
visibility: accessType.visibility,
|
visibility: accessType.visibility,
|
||||||
preset: accessType.preset,
|
preset: accessType.preset,
|
||||||
|
|||||||
+1
-1
Submodule Enterprise updated: ad58607116...5680a2d94b
@@ -434,13 +434,24 @@ final class SecurityAndPrivacyScreenViewModelTests {
|
|||||||
try await deferred.fulfill()
|
try await deferred.fulfill()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
func encryptionOptionAvailability() {
|
||||||
|
setupViewModel(joinedParentSpaces: [], joinRule: .public)
|
||||||
|
#expect(context.viewState.canEnableEncryption)
|
||||||
|
|
||||||
|
setupViewModel(joinedParentSpaces: [], joinRule: .public, forceDisableE2EE: true)
|
||||||
|
#expect(!context.viewState.canEnableEncryption)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Helpers
|
// MARK: - Helpers
|
||||||
|
|
||||||
private func setupViewModel(joinedParentSpaces: [SpaceServiceRoom],
|
private func setupViewModel(joinedParentSpaces: [SpaceServiceRoom],
|
||||||
topLevelSpaces: [SpaceServiceRoom] = [],
|
topLevelSpaces: [SpaceServiceRoom] = [],
|
||||||
joinRule: ElementX.JoinRule) {
|
joinRule: ElementX.JoinRule,
|
||||||
|
forceDisableE2EE: Bool = false) {
|
||||||
let appSettings = AppSettings.volatile()
|
let appSettings = AppSettings.volatile()
|
||||||
appSettings.knockingEnabled = true
|
appSettings.knockingEnabled = true
|
||||||
|
appSettings.forceDisableE2EE.applyRemoteValue(forceDisableE2EE)
|
||||||
roomProxy = JoinedRoomProxyMock(.init(isEncrypted: false,
|
roomProxy = JoinedRoomProxyMock(.init(isEncrypted: false,
|
||||||
canonicalAlias: "#room:matrix.org",
|
canonicalAlias: "#room:matrix.org",
|
||||||
members: .allMembersAsCreator,
|
members: .allMembersAsCreator,
|
||||||
|
|||||||
Reference in New Issue
Block a user