mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-04-01 09:04:03 +00:00
chore: fix conversation type not used
This commit is contained in:
parent
66c2abe6de
commit
c4566bb7ce
@ -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(
|
||||
|
||||
@ -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),
|
||||
}
|
||||
|
||||
@ -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)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user