add nip4e settings

This commit is contained in:
2026-06-04 16:06:16 +07:00
parent 1f04a824d7
commit ce8f431aaa
4 changed files with 60 additions and 26 deletions

View File

@@ -40,6 +40,7 @@ setting_accessors! {
pub theme_mode: ThemeMode,
pub hide_avatar: bool,
pub screening: bool,
pub encryption_key: bool,
pub auth_mode: AuthMode,
pub trusted_relays: HashSet<RelayUrl>,
pub room_configs: HashMap<u64, RoomConfig>,
@@ -137,6 +138,11 @@ pub struct Settings {
/// Enable screening for unknown chat requests
pub screening: bool,
/// Enable decoupling encryption key
///
/// NIP-4e
pub encryption_key: bool,
/// Authentication mode
pub auth_mode: AuthMode,
@@ -157,6 +163,7 @@ impl Default for Settings {
theme_mode: ThemeMode::default(),
hide_avatar: false,
screening: true,
encryption_key: false,
auth_mode: AuthMode::default(),
trusted_relays: HashSet::default(),
room_configs: HashMap::default(),
@@ -301,6 +308,11 @@ impl AppSettings {
}
}
/// Check if decoupling encryption key is enabled
pub fn is_nip4e_enabled(&self) -> bool {
self.values.encryption_key
}
/// Check if the given relay is already authenticated
pub fn trusted_relay(&self, url: &RelayUrl, _cx: &App) -> bool {
self.values.trusted_relays.iter().any(|relay| {