From 585439b2ab37a582bfb8d78399784e3131a8ddea Mon Sep 17 00:00:00 2001 From: Schmiddiii Date: Sat, 4 Mar 2023 15:00:20 +0100 Subject: [PATCH] Fix storing messages Currently, message timestamps are encrypted when storing. This does not work when retrieving messages before a timestamp (and I think currently does not work when getting/deleting messages in general). This PR fixes this by just removing the encryption. Before this PR should actually be merged, it should maybe be discussed if removing the encryption is actually a good thing to do, but as far as I see it is the only thing possible except for every time we look for messages of a thread, decrypt all message keys and manually sort and iterate them. --- src/store/sled.rs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/store/sled.rs b/src/store/sled.rs index 3132eb6cd..8fefe60ab 100644 --- a/src/store/sled.rs +++ b/src/store/sled.rs @@ -158,16 +158,6 @@ impl SledStore { self.db.open_tree(tree).map_err(Error::DbError) } - fn key(&self, tree: &str, key: K) -> Vec - where - K: AsRef<[u8]>, - { - self.cipher.as_ref().map_or_else( - || key.as_ref().to_vec(), - |c| c.hash_key(tree, key.as_ref()).to_vec(), - ) - } - pub fn get(&self, tree: &str, key: K) -> Result, Error> where K: AsRef<[u8]>, @@ -743,7 +733,6 @@ impl MessageStore for SledStore { let proto: ContentProto = message.into(); let tree = self.messages_thread_tree_name(thread); - let key = self.key(&tree, timestamp_bytes); let value = proto.encode_to_vec(); let value = self.cipher.as_ref().map_or_else( @@ -751,7 +740,7 @@ impl MessageStore for SledStore { |c| c.encrypt_value(&value).map_err(Error::from), )?; - let _ = self.tree(tree)?.insert(key, value)?; + let _ = self.tree(tree)?.insert(timestamp_bytes, value)?; Ok(()) }