chore: fix conversation type not used

This commit is contained in:
kaichaosun 2026-03-27 15:31:47 +08:00
parent 66c2abe6de
commit c4566bb7ce
No known key found for this signature in database
GPG Key ID: 223E0F992F4F03BF
3 changed files with 19 additions and 9 deletions

View File

@ -175,6 +175,13 @@ impl Context {
.load_conversation(convo_id)?
.ok_or_else(|| ChatError::NoConvo(convo_id.into()))?;
if record.convo_type != "private_v1" {
return Err(ChatError::BadBundleValue(format!(
"unsupported conversation type: {}",
record.convo_type
)));
}
let dr_state: RatchetState = self.ratchet_storage.load(&record.local_convo_id)?;
Ok(PrivateV1Convo::from_stored(

View File

@ -22,6 +22,8 @@ pub enum ChatError {
BadParsing(&'static str),
#[error("convo with id: {0} was not found")]
NoConvo(String),
#[error("unsupported conversation type: {0}")]
UnsupportedConvoType(String),
#[error("storage error: {0}")]
Storage(#[from] StorageError),
}

View File

@ -180,6 +180,16 @@ impl ChatStorage {
Ok(exists)
}
/// Removes a conversation by its local ID.
#[allow(dead_code)]
pub fn remove_conversation(&mut self, local_convo_id: &str) -> Result<(), StorageError> {
self.db.connection().execute(
"DELETE FROM conversations WHERE local_convo_id = ?1",
params![local_convo_id],
)?;
Ok(())
}
/// Loads a single conversation record by its local ID.
pub fn load_conversation(
&self,
@ -223,15 +233,6 @@ impl ChatStorage {
Ok(records)
}
/// Removes a conversation by its local ID.
pub fn remove_conversation(&mut self, local_convo_id: &str) -> Result<(), StorageError> {
self.db.connection().execute(
"DELETE FROM conversations WHERE local_convo_id = ?1",
params![local_convo_id],
)?;
Ok(())
}
}
#[cfg(test)]