Skip to content

Commit

Permalink
Update presage and downstream libs (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
gferon authored Mar 14, 2023
1 parent cbb3c0b commit 3f2c9d9
Showing 7 changed files with 14 additions and 12 deletions.
10 changes: 6 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ debug = true
dev = ["prost", "base64"]

[dependencies]
presage = { git = "https://github.com/whisperfish/presage", rev = "faef707" }
presage = { git = "https://github.com/whisperfish/presage", rev = "d1d72ab" }

anyhow = "1.0.66"
async-trait = "0.1.58"
6 changes: 3 additions & 3 deletions src/dev.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::fs::OpenOptions;
use std::io::BufWriter;

use anyhow::anyhow;
use presage::prelude::proto;
use presage::prelude::{Content, Metadata, ServiceAddress};
use prost::Message;
@@ -21,6 +20,7 @@ struct MetadataDef {
sender_device: u32,
timestamp: u64,
needs_receipt: bool,
unidentified_sender: bool,
}

impl From<Metadata> for MetadataDef {
@@ -30,6 +30,7 @@ impl From<Metadata> for MetadataDef {
sender_device: metadata.sender_device,
timestamp: metadata.timestamp,
needs_receipt: metadata.needs_receipt,
unidentified_sender: metadata.unidentified_sender,
}
}
}
@@ -51,8 +52,7 @@ impl TryFrom<ContentBase64> for Content {
fn try_from(content: ContentBase64) -> Result<Self, Self::Error> {
let content_bytes = base64::decode(&content.content_proto_base64)?;
let content_proto = proto::Content::decode(&*content_bytes)?;
Self::from_proto(content_proto, content.metadata)
.ok_or_else(|| anyhow!("invalid content proto"))
Ok(Self::from_proto(content_proto, content.metadata)?)
}
}

2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ pub enum Event {
}

async fn run_single_threaded(relink: bool) -> anyhow::Result<()> {
let (signal_manager, config) = signal::ensure_linked_device(relink).await?;
let (mut signal_manager, config) = signal::ensure_linked_device(relink).await?;

let storage = JsonStorage::new(&config.data_path, config::fallback_data_path().as_deref())?;
let mut app = App::try_new(config, signal_manager.clone_boxed(), Box::new(storage))?;
2 changes: 1 addition & 1 deletion src/signal/impl.rs
Original file line number Diff line number Diff line change
@@ -289,7 +289,7 @@ impl SignalManager for PresageManager {
Ok(self.manager.get_contact_by_id(id)?)
}

async fn receive_messages(&self) -> anyhow::Result<Pin<Box<dyn Stream<Item = Content>>>> {
async fn receive_messages(&mut self) -> anyhow::Result<Pin<Box<dyn Stream<Item = Content>>>> {
Ok(Box::pin(self.manager.receive_messages().await?))
}
}
2 changes: 1 addition & 1 deletion src/signal/manager.rs
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ pub trait SignalManager {
/// This usually happens shortly after the latter method is called.
fn contact_by_id(&self, id: Uuid) -> anyhow::Result<Option<Contact>>;

async fn receive_messages(&self) -> anyhow::Result<Pin<Box<dyn Stream<Item = Content>>>>;
async fn receive_messages(&mut self) -> anyhow::Result<Pin<Box<dyn Stream<Item = Content>>>>;
}

pub struct ResolvedGroup {
2 changes: 1 addition & 1 deletion src/signal/test.rs
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ impl SignalManager for SignalManagerMock {
Ok(None)
}

async fn receive_messages(&self) -> anyhow::Result<Pin<Box<dyn Stream<Item = Content>>>> {
async fn receive_messages(&mut self) -> anyhow::Result<Pin<Box<dyn Stream<Item = Content>>>> {
Ok(Box::pin(tokio_stream::empty()))
}

0 comments on commit 3f2c9d9

Please sign in to comment.