Update WellKnown & HomeserverConfiguration for mandatory backup

This commit is contained in:
Arnaud Ringenbach
2022-03-09 10:40:33 +01:00
parent 1af1da145f
commit 3325c5341d
10 changed files with 201 additions and 19 deletions

View File

@@ -28,10 +28,6 @@ final class HomeserverConfigurationBuilder: NSObject {
/// Create an `HomeserverConfiguration` from an HS Well-Known when possible otherwise it takes hardcoded values from BuildSettings by default.
func build(from wellKnown: MXWellKnown?) -> HomeserverConfiguration {
let isE2EEByDefaultEnabled: Bool
let jitsiPreferredDomain: String
var vectorWellKnownEncryptionConfiguration: VectorWellKnownEncryptionConfiguration?
var vectorWellKnownJitsiConfiguration: VectorWellKnownJitsiConfiguration?
@@ -39,12 +35,29 @@ final class HomeserverConfigurationBuilder: NSObject {
vectorWellKnownEncryptionConfiguration = self.getEncryptionConfiguration(from: vectorWellKnown)
vectorWellKnownJitsiConfiguration = self.getJitsiConfiguration(from: vectorWellKnown)
}
// Encryption configuration
// Enable E2EE by default when there is no value
isE2EEByDefaultEnabled = vectorWellKnownEncryptionConfiguration?.isE2EEByDefaultEnabled ?? true
let isE2EEByDefaultEnabled = vectorWellKnownEncryptionConfiguration?.isE2EEByDefaultEnabled ?? true
// Disable mandatory secure backup when there is no value
let isSecureBackupRequired = vectorWellKnownEncryptionConfiguration?.isSecureBackupRequired ?? false
// Default to `MXKKeyPreSharingWhenTyping` when there is no value
let outboundKeysPreSharingMode = vectorWellKnownEncryptionConfiguration?.outboundKeysPreSharingMode ?? .whenTyping
// Defaults to all secure backup methods available when there is no value
let secureBackupSetupMethods: [VectorWellKnownBackupSetupMethod]
if let backupSetupMethods = vectorWellKnownEncryptionConfiguration?.secureBackupSetupMethods {
secureBackupSetupMethods = backupSetupMethods.isEmpty ? VectorWellKnownBackupSetupMethod.allCases : backupSetupMethods
} else {
secureBackupSetupMethods = VectorWellKnownBackupSetupMethod.allCases
}
let encryptionConfiguration = HomeserverEncryptionConfiguration(isE2EEByDefaultEnabled: isE2EEByDefaultEnabled,
isSecureBackupRequired: isSecureBackupRequired,
secureBackupSetupMethods: secureBackupSetupMethods,
outboundKeysPreSharingMode: outboundKeysPreSharingMode)
// Jitsi configuration
let jitsiPreferredDomain: String
let jitsiServerURL: URL
let hardcodedJitsiServerURL: URL = BuildSettings.jitsiServerUrl
@@ -77,7 +90,7 @@ final class HomeserverConfigurationBuilder: NSObject {
serverURL: jitsiServerURL)
return HomeserverConfiguration(jitsi: jitsiConfiguration,
isE2EEByDefaultEnabled: isE2EEByDefaultEnabled,
encryption: encryptionConfiguration,
tileServer: tileServerConfiguration)
}