Skip to content

Commit

Permalink
Use fix linking from libsignal-service-rs
Browse files Browse the repository at this point in the history
Co-authored-by: Boxdot <[email protected]>
  • Loading branch information
gferon and boxdot committed Dec 16, 2023
1 parent 5623f68 commit fab47c6
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 275 deletions.
2 changes: 1 addition & 1 deletion presage-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Gabriel Féron <[email protected]>"]
presage = { path = "../presage" }
presage-store-sled = { path = "../presage-store-sled" }

anyhow = "1.0"
anyhow = { version = "1.0", features = ["backtrace"] }
base64 = "0.12"
chrono = { version = "0.4", default-features = false, features = ["serde", "clock"] }
clap = { version = ">=4.2.4", features = ["derive"] }
Expand Down
37 changes: 21 additions & 16 deletions presage-store-sled/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use presage::libsignal_service::{
content::Content,
groups_v2::Group,
models::Contact,
pre_keys::PreKeysStore,
prelude::{ProfileKey, Uuid},
protocol::{
Direction, GenericSignedPreKey, IdentityKey, IdentityKeyPair, IdentityKeyStore,
Expand All @@ -24,7 +25,7 @@ use presage::libsignal_service::{
session_store::SessionStoreExt,
Profile, ServiceAddress,
};
use presage::store::{ContentExt, ContentsStore, PreKeyStoreExt, StateStore, Store, Thread};
use presage::store::{ContentExt, ContentsStore, StateStore, Store, Thread};
use presage::{manager::RegistrationData, proto::verified};
use prost::Message;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
Expand Down Expand Up @@ -603,39 +604,43 @@ impl ContentsStore for SledStore {
}
}

impl PreKeyStoreExt for SledStore {
type PreKeyStoreExtError = SledStoreError;

fn pre_keys_offset_id(&self) -> Result<u32, SledStoreError> {
impl PreKeysStore for SledStore {
fn pre_keys_offset_id(&self) -> Result<u32, SignalProtocolError> {
Ok(self
.get(SLED_TREE_STATE, SLED_KEY_PRE_KEYS_OFFSET_ID)?
.get(SLED_TREE_STATE, SLED_KEY_PRE_KEYS_OFFSET_ID)
.map_err(|_| SignalProtocolError::InvalidPreKeyId)?
.unwrap_or(0))
}

fn set_pre_keys_offset_id(&mut self, id: u32) -> Result<(), SledStoreError> {
self.insert(SLED_TREE_STATE, SLED_KEY_PRE_KEYS_OFFSET_ID, id)?;
fn set_pre_keys_offset_id(&mut self, id: u32) -> Result<(), SignalProtocolError> {
self.insert(SLED_TREE_STATE, SLED_KEY_PRE_KEYS_OFFSET_ID, id)
.map_err(|_| SignalProtocolError::InvalidPreKeyId)?;
Ok(())
}

fn next_signed_pre_key_id(&self) -> Result<u32, SledStoreError> {
fn next_signed_pre_key_id(&self) -> Result<u32, SignalProtocolError> {
Ok(self
.get(SLED_TREE_STATE, SLED_KEY_NEXT_SIGNED_PRE_KEY_ID)?
.get(SLED_TREE_STATE, SLED_KEY_NEXT_SIGNED_PRE_KEY_ID)
.map_err(|_| SignalProtocolError::InvalidSignedPreKeyId)?
.unwrap_or(0))
}

fn set_next_signed_pre_key_id(&mut self, id: u32) -> Result<(), SledStoreError> {
self.insert(SLED_TREE_STATE, SLED_KEY_NEXT_SIGNED_PRE_KEY_ID, id)?;
fn set_next_signed_pre_key_id(&mut self, id: u32) -> Result<(), SignalProtocolError> {
self.insert(SLED_TREE_STATE, SLED_KEY_NEXT_SIGNED_PRE_KEY_ID, id)
.map_err(|_| SignalProtocolError::InvalidSignedPreKeyId)?;
Ok(())
}

fn next_pq_pre_key_id(&self) -> Result<u32, SledStoreError> {
fn next_pq_pre_key_id(&self) -> Result<u32, SignalProtocolError> {
Ok(self
.get(SLED_TREE_STATE, SLED_KEY_NEXT_PQ_PRE_KEY_ID)?
.get(SLED_TREE_STATE, SLED_KEY_NEXT_PQ_PRE_KEY_ID)
.map_err(|_| SignalProtocolError::InvalidKyberPreKeyId)?
.unwrap_or(0))
}

fn set_next_pq_pre_key_id(&mut self, id: u32) -> Result<(), SledStoreError> {
self.insert(SLED_TREE_STATE, SLED_KEY_NEXT_PQ_PRE_KEY_ID, id)?;
fn set_next_pq_pre_key_id(&mut self, id: u32) -> Result<(), SignalProtocolError> {
self.insert(SLED_TREE_STATE, SLED_KEY_NEXT_PQ_PRE_KEY_ID, id)
.map_err(|_| SignalProtocolError::InvalidKyberPreKeyId)?;
Ok(())
}
}
Expand Down
Loading

0 comments on commit fab47c6

Please sign in to comment.