mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-03-26 22:23:14 +00:00
fix: clean
This commit is contained in:
parent
3a9ddadc88
commit
7019b04ccb
@ -31,6 +31,7 @@ pub struct Context {
|
||||
_identity: Rc<Identity>,
|
||||
store: ConversationStore,
|
||||
inbox: Inbox,
|
||||
#[allow(dead_code)] // Will be used for conversation persistence
|
||||
storage: ChatStorage,
|
||||
}
|
||||
|
||||
|
||||
@ -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)]
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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<IdentityRecord> for Identity {
|
||||
fn from(record: IdentityRecord) -> Self {
|
||||
let secret = PrivateKey::from(record.secret_key);
|
||||
|
||||
@ -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<Self, StorageError> {
|
||||
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)?;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user