aboutsummaryrefslogtreecommitdiff
path: root/crates/chat-server/src/store.rs
diff options
context:
space:
mode:
authorDoan Luu Duc Tai <doan@luuduct.ai>2026-10-30 22:12:54 -0500
committerDoan Luu Duc Tai <doan@luuduct.ai>2026-10-30 22:12:54 -0500
commitbe16d00a8a4750028073e018ab2c58d54af192c4 (patch)
tree3eeabb31508f98a6753a2492238581f888769b4a /crates/chat-server/src/store.rs
parentb7374fe09306c495131cf3673addb76a1dcf017d (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.rs13
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)",