Fix disable MSC3061 lab for rust crypto

This commit is contained in:
valere 2023-02-03 10:59:47 +01:00
parent 2f1e282950
commit 6f859c9ca6
4 changed files with 20 additions and 9 deletions

View file

@ -1187,6 +1187,8 @@ internal class DefaultCryptoService @Inject constructor(
override fun isShareKeysOnInviteEnabled() = cryptoStore.isShareKeysOnInviteEnabled() override fun isShareKeysOnInviteEnabled() = cryptoStore.isShareKeysOnInviteEnabled()
override fun supportsShareKeysOnInvite() = true
override fun enableShareKeyOnInvite(enable: Boolean) = cryptoStore.enableShareKeyOnInvite(enable) override fun enableShareKeyOnInvite(enable: Boolean) = cryptoStore.enableShareKeyOnInvite(enable)
/** /**

View file

@ -89,6 +89,10 @@ interface CryptoService {
fun isKeyGossipingEnabled(): Boolean fun isKeyGossipingEnabled(): Boolean
/*
* Tells if the current crypto implementation supports MSC3061
*/
fun supportsShareKeysOnInvite(): Boolean
/** /**
* As per MSC3061. * As per MSC3061.
* If true will make it possible to share part of e2ee room history * If true will make it possible to share part of e2ee room history

View file

@ -724,15 +724,15 @@ internal class RustCryptoService @Inject constructor(
return cryptoStore.isKeyGossipingEnabled() return cryptoStore.isKeyGossipingEnabled()
} }
override fun supportsShareKeysOnInvite() = false
override fun enableShareKeyOnInvite(enable: Boolean) { override fun enableShareKeyOnInvite(enable: Boolean) {
if (enable) { if (enable) {
TODO("Enable share key on invite not implemented") TODO("Enable share key on invite not implemented")
} }
} }
override fun isShareKeysOnInviteEnabled(): Boolean { override fun isShareKeysOnInviteEnabled() = false
return false
}
override fun setRoomUnBlockUnverifiedDevices(roomId: String) { override fun setRoomUnBlockUnverifiedDevices(roomId: String) {
cryptoStore.blockUnverifiedDevicesInRoom(roomId, false) cryptoStore.blockUnverifiedDevicesInRoom(roomId, false)

View file

@ -72,13 +72,18 @@ class VectorSettingsLabsFragment :
} }
findPreference<SwitchPreference>(VectorPreferences.SETTINGS_LABS_MSC3061_SHARE_KEYS_HISTORY)?.let { pref -> findPreference<SwitchPreference>(VectorPreferences.SETTINGS_LABS_MSC3061_SHARE_KEYS_HISTORY)?.let { pref ->
// ensure correct default if (session.cryptoService().supportsShareKeysOnInvite()) {
pref.isChecked = session.cryptoService().isShareKeysOnInviteEnabled() // ensure correct default
pref.isChecked = session.cryptoService().isShareKeysOnInviteEnabled()
pref.onPreferenceClickListener = Preference.OnPreferenceClickListener { pref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
session.cryptoService().enableShareKeyOnInvite(pref.isChecked) session.cryptoService().enableShareKeyOnInvite(pref.isChecked)
MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = true)) MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = true))
true true
}
} else {
pref.isEnabled = false
pref.isChecked = false
} }
} }