diff options
| author | Doan Luu Duc Tai <doan@luuduct.ai> | 2026-10-30 22:12:54 -0500 |
|---|---|---|
| committer | Doan Luu Duc Tai <doan@luuduct.ai> | 2026-10-30 22:12:54 -0500 |
| commit | c3b361c45ac8dd898d5c83a161abed5fc138b6c0 (patch) | |
| tree | 3eeabb31508f98a6753a2492238581f888769b4a /crates/chat-server/src/store.rs | |
| parent | 3034705b6679bff1802c4180b7b4711b94fed7f9 (diff) | |
Refine chat controls and add explicit owner recovery reset
Simplify the ASCII interface, expose owner setup, and load any selected number of messages using bounded history batches. Add backend-only owner reset with a matching public fingerprint and stopped-service guards, and document the loss of old history and key continuity.
Diffstat (limited to 'crates/chat-server/src/store.rs')
| -rw-r--r-- | crates/chat-server/src/store.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/chat-server/src/store.rs b/crates/chat-server/src/store.rs index fce3bb3..0e09de7 100644 --- a/crates/chat-server/src/store.rs +++ b/crates/chat-server/src/store.rs @@ -45,6 +45,19 @@ impl Store { Ok(()) } + pub(crate) fn reset_owner(&mut self, expected: &str) -> Result<()> { + let owner = self.owner()?.context("No owner identity is registered")?; + let fingerprint = stack_chat_crypto::public_identity(&owner)?; + ensure!( + expected.len() == 64 && expected.eq_ignore_ascii_case(&fingerprint), + "Owner fingerprint does not match; no data was cleared" + ); + let transaction = self.connection.transaction()?; + transaction.execute_batch("DELETE FROM messages; DELETE FROM conversations; DELETE FROM metadata WHERE key='owner'; DELETE FROM sqlite_sequence WHERE name='messages';")?; + transaction.commit()?; + Ok(()) + } + pub(crate) fn register(&self, id: &str, cert: &str) -> Result<()> { if self.connection.query_row( "SELECT EXISTS(SELECT 1 FROM conversations WHERE id=?1)", |
