From c3b361c45ac8dd898d5c83a161abed5fc138b6c0 Mon Sep 17 00:00:00 2001 From: Doan Luu Duc Tai Date: Fri, 30 Oct 2026 22:12:54 -0500 Subject: 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. --- crates/chat-server/src/store.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'crates/chat-server/src/store.rs') 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)", -- cgit v1.2.3