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 supportsShareKeysOnInvite() = true
override fun enableShareKeyOnInvite(enable: Boolean) = cryptoStore.enableShareKeyOnInvite(enable)
/**

View File

@ -89,6 +89,10 @@ interface CryptoService {
fun isKeyGossipingEnabled(): Boolean
/*
* Tells if the current crypto implementation supports MSC3061
*/
fun supportsShareKeysOnInvite(): Boolean
/**
* As per MSC3061.
* 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()
}
override fun supportsShareKeysOnInvite() = false
override fun enableShareKeyOnInvite(enable: Boolean) {
if (enable) {
TODO("Enable share key on invite not implemented")
}
}
override fun isShareKeysOnInviteEnabled(): Boolean {
return false
}
override fun isShareKeysOnInviteEnabled() = false
override fun setRoomUnBlockUnverifiedDevices(roomId: String) {
cryptoStore.blockUnverifiedDevicesInRoom(roomId, false)

View File

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