- E2EE crypto (src/e2ee.rs) with X25519 key derivation from Ed25519, HKDF shared secret, ChaCha20-Poly1305 encrypt/decrypt - E2EE net layer: PID 0x0071-0x0074, JSON payloads, dispatch, session handlers - E2EE UI: lock icons in DM header and sidebar - Slint migration: all .slint files, bridge.rs, update.rs, main.rs - Removed egui UI (~50 files), cleaned all dead code - Clean cargo clippy -- -D warnings
66 lines
1.4 KiB
Rust
66 lines
1.4 KiB
Rust
use std::collections::HashMap;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct Channel {
|
|
pub id: String,
|
|
pub name: String,
|
|
pub kind: String,
|
|
pub members: Vec<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct ChatMessage {
|
|
pub message_id: String,
|
|
pub sender_id: String,
|
|
pub content: String,
|
|
pub timestamp: i64,
|
|
pub edited: bool,
|
|
pub reactions: HashMap<String, Vec<String>>,
|
|
/// Optional message_id this message is replying to.
|
|
#[cfg_attr(not(test), allow(dead_code))]
|
|
pub reply_to: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct DmConversation {
|
|
pub dm_id: String,
|
|
pub other_nickname: String,
|
|
pub unread_count: u32,
|
|
pub e2ee_enabled: bool,
|
|
pub e2ee_peer_public_key: Option<Vec<u8>>,
|
|
pub e2ee_shared_secret: Option<[u8; 32]>,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct GuildState {
|
|
pub guild_id: String,
|
|
pub name: String,
|
|
pub member_count: u32,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct FriendState {
|
|
pub user_id: String,
|
|
pub nickname: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct NodeBookmark {
|
|
pub label: String,
|
|
pub address: String,
|
|
}
|
|
|
|
pub(crate) fn default_bookmarks() -> Vec<NodeBookmark> {
|
|
Vec::new()
|
|
}
|
|
|
|
pub(crate) fn bookmark_label_from_address(address: &str) -> String {
|
|
address
|
|
.split(':')
|
|
.next()
|
|
.filter(|s| !s.is_empty())
|
|
.unwrap_or(address)
|
|
.chars()
|
|
.take(12)
|
|
.collect()
|
|
}
|