From 7019b04ccb2405f8999e061c79592f0b2123d9d9 Mon Sep 17 00:00:00 2001 From: kaichaosun Date: Fri, 27 Feb 2026 14:57:25 +0800 Subject: [PATCH] fix: clean --- conversations/src/context.rs | 1 + conversations/src/errors.rs | 2 -- .../storage/migrations/001_initial_schema.sql | 18 ------------------ conversations/src/storage/types.rs | 9 --------- storage/src/sqlite.rs | 16 +--------------- 5 files changed, 2 insertions(+), 44 deletions(-) diff --git a/conversations/src/context.rs b/conversations/src/context.rs index 87a68fe..fe410d0 100644 --- a/conversations/src/context.rs +++ b/conversations/src/context.rs @@ -31,6 +31,7 @@ pub struct Context { _identity: Rc, store: ConversationStore, inbox: Inbox, + #[allow(dead_code)] // Will be used for conversation persistence storage: ChatStorage, } diff --git a/conversations/src/errors.rs b/conversations/src/errors.rs index 1df0e68..d551960 100644 --- a/conversations/src/errors.rs +++ b/conversations/src/errors.rs @@ -20,8 +20,6 @@ pub enum ChatError { BadParsing(&'static str), #[error("convo with id: {0} was not found")] NoConvo(String), - #[error("session error: {0}")] - Session(#[from] double_ratchets::SessionError), } #[derive(Error, Debug)] diff --git a/conversations/src/storage/migrations/001_initial_schema.sql b/conversations/src/storage/migrations/001_initial_schema.sql index 70b5359..5a97bfe 100644 --- a/conversations/src/storage/migrations/001_initial_schema.sql +++ b/conversations/src/storage/migrations/001_initial_schema.sql @@ -7,21 +7,3 @@ CREATE TABLE IF NOT EXISTS identity ( name TEXT NOT NULL, secret_key BLOB NOT NULL ); - --- Inbox ephemeral keys for handshakes -CREATE TABLE IF NOT EXISTS inbox_keys ( - public_key_hex TEXT PRIMARY KEY, - secret_key BLOB NOT NULL, - created_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now')) -); - --- Chat metadata -CREATE TABLE IF NOT EXISTS chats ( - chat_id TEXT PRIMARY KEY, - chat_type TEXT NOT NULL, - remote_public_key BLOB, - remote_address TEXT NOT NULL, - created_at INTEGER NOT NULL -); - -CREATE INDEX IF NOT EXISTS idx_chats_type ON chats(chat_type); diff --git a/conversations/src/storage/types.rs b/conversations/src/storage/types.rs index d82a421..d4d48d9 100644 --- a/conversations/src/storage/types.rs +++ b/conversations/src/storage/types.rs @@ -12,15 +12,6 @@ pub struct IdentityRecord { pub secret_key: [u8; 32], } -impl From<&Identity> for IdentityRecord { - fn from(identity: &Identity) -> Self { - Self { - name: identity.get_name().to_string(), - secret_key: identity.secret().DANGER_to_bytes(), - } - } -} - impl From for Identity { fn from(record: IdentityRecord) -> Self { let secret = PrivateKey::from(record.secret_key); diff --git a/storage/src/sqlite.rs b/storage/src/sqlite.rs index 8449532..4d42e9d 100644 --- a/storage/src/sqlite.rs +++ b/storage/src/sqlite.rs @@ -8,11 +8,8 @@ use crate::StorageError; /// Configuration for SQLite storage. #[derive(Debug, Clone)] pub enum StorageConfig { - /// In-memory database (isolated, for simple testing). + /// In-memory database (for testing). InMemory, - /// Shared in-memory database with a name (multiple connections share data). - /// Use this when you need multiple storage instances to share the same in-memory DB. - SharedInMemory(String), /// File-based SQLite database. File(String), /// SQLCipher encrypted database. @@ -32,17 +29,6 @@ impl SqliteDb { pub fn new(config: StorageConfig) -> Result { let conn = match config { StorageConfig::InMemory => Connection::open_in_memory()?, - StorageConfig::SharedInMemory(ref name) => { - // Use URI mode to create a shared in-memory database - // Multiple connections with the same name share the same data - let uri = format!("file:{}?mode=memory&cache=shared", name); - Connection::open_with_flags( - &uri, - rusqlite::OpenFlags::SQLITE_OPEN_URI - | rusqlite::OpenFlags::SQLITE_OPEN_READ_WRITE - | rusqlite::OpenFlags::SQLITE_OPEN_CREATE, - )? - } StorageConfig::File(ref path) => Connection::open(path)?, StorageConfig::Encrypted { ref path, ref key } => { let conn = Connection::open(path)?;