Skip to content

Commit

Permalink
Bump presage to 23c157b (#253)
Browse files Browse the repository at this point in the history
In particular, this auto-trusts new identity keys.
  • Loading branch information
gferon authored Nov 22, 2023
1 parent c7f6431 commit 0278d4c
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 44 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ debug = true
dev = ["prost", "base64"]

[dependencies]
presage = { git = "https://github.com/whisperfish/presage", rev = "de23104" }
presage-store-sled = { git = "https://github.com/whisperfish/presage", rev = "de23104" }
presage = { git = "https://github.com/whisperfish/presage", rev = "23c157b" }
presage-store-sled = { git = "https://github.com/whisperfish/presage", rev = "23c157b" }

anyhow = "1.0.66"
async-trait = "0.1.58"
Expand Down
17 changes: 8 additions & 9 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ use image::{ImageBuffer, ImageEncoder, Rgba};
use itertools::Itertools;
use notify_rust::Notification;
use phonenumber::Mode;
use presage::prelude::proto::{AttachmentPointer, ReceiptMessage, TypingMessage};
use presage::prelude::{
content::{ContentBody, DataMessage, Metadata, SyncMessage},
proto::{
data_message::{Reaction, Sticker},
sync_message::Sent,
GroupContextV2,
},
AttachmentSpec, Content, ServiceAddress,
use presage::libsignal_service::content::{Content, ContentBody, Metadata};
use presage::libsignal_service::sender::AttachmentSpec;
use presage::libsignal_service::ServiceAddress;
use presage::proto::{
data_message::{Reaction, Sticker},
sync_message::Sent,
GroupContextV2,
};
use presage::proto::{AttachmentPointer, DataMessage, ReceiptMessage, SyncMessage, TypingMessage};
use regex_automata::Regex;
use tokio::sync::mpsc;
use tracing::{error, info, trace, warn};
Expand Down
5 changes: 3 additions & 2 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
use std::collections::HashSet;

use anyhow::anyhow;
use presage::prelude::proto::data_message::Quote;
use presage::prelude::{proto, GroupMasterKey, GroupSecretParams};
use presage::libsignal_service::zkgroup::groups::{GroupMasterKey, GroupSecretParams};
use presage::proto;
use presage::proto::data_message::Quote;
use serde::{Deserialize, Serialize};
use tracing::error;
use uuid::Uuid;
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crossterm::{
use gurk::app::App;
use gurk::storage::{sync_from_signal, JsonStorage, MemCache, SqliteStorage, Storage};
use gurk::{config, signal, ui};
use presage::prelude::Content;
use presage::libsignal_service::content::Content;
use ratatui::{backend::CrosstermBackend, Terminal};
use tokio::select;
use tokio_stream::StreamExt;
Expand Down
2 changes: 1 addition & 1 deletion src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl ReceiptHandler {
// over the current session
self.receipt_set
.entry(event.uuid)
.or_insert_with(ReceiptQueues::new)
.or_default()
.add(event.timestamp, event.receipt_type);
}

Expand Down
47 changes: 33 additions & 14 deletions src/signal/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use std::pin::Pin;
use anyhow::{anyhow, Context};
use async_trait::async_trait;
use chrono::Utc;
use presage::libsignal_service::content::{Content, ContentBody};
use presage::libsignal_service::models::Contact;
use presage::libsignal_service::prelude::{Group, ProfileKey};
use presage::prelude::content::Reaction;
use presage::prelude::proto::data_message::Quote;
use presage::prelude::proto::{AttachmentPointer, ReceiptMessage};
use presage::prelude::{
AttachmentSpec, Contact, Content, ContentBody, DataMessage, GroupContextV2,
};
use presage::Registered;
use presage::libsignal_service::sender::AttachmentSpec;
use presage::manager::{ReceivingMode, Registered};
use presage::proto::data_message::{Quote, Reaction};
use presage::proto::{AttachmentPointer, DataMessage, GroupContextV2, ReceiptMessage};
use presage::store::ContentsStore;
use presage_store_sled::SledStore;
use tokio::sync::oneshot;
use tokio_stream::Stream;
Expand Down Expand Up @@ -42,7 +42,7 @@ impl SignalManager for PresageManager {
}

fn user_id(&self) -> Uuid {
self.manager.state().service_ids.aci
self.manager.registration_data().service_ids.aci
}

async fn resolve_group(
Expand All @@ -51,7 +51,8 @@ impl SignalManager for PresageManager {
) -> anyhow::Result<ResolvedGroup> {
let decrypted_group = self
.manager
.group(&master_key_bytes)?
.store()
.group(master_key_bytes)?
.context("no group found")?;

let mut members = Vec::with_capacity(decrypted_group.members.len());
Expand Down Expand Up @@ -308,23 +309,41 @@ impl SignalManager for PresageManager {
}

async fn request_contacts_sync(&self) -> anyhow::Result<()> {
Ok(self.manager.clone().request_contacts_sync().await?)
Ok(self.manager.clone().sync_contacts().await?)
}

fn contact_by_id(&self, id: Uuid) -> anyhow::Result<Option<Contact>> {
Ok(self.manager.contact_by_id(&id)?)
Ok(self.manager.store().contact_by_id(&id)?)
}

async fn receive_messages(&mut self) -> anyhow::Result<Pin<Box<dyn Stream<Item = Content>>>> {
Ok(Box::pin(self.manager.receive_messages().await?))
Ok(Box::pin(
self.manager
.receive_messages(ReceivingMode::Forever)
.await?,
))
}

fn contacts(&self) -> Box<dyn Iterator<Item = Contact>> {
Box::new(self.manager.contacts().into_iter().flatten().flatten())
Box::new(
self.manager
.store()
.contacts()
.into_iter()
.flatten()
.flatten(),
)
}

fn groups(&self) -> Box<dyn Iterator<Item = (GroupMasterKeyBytes, Group)>> {
Box::new(self.manager.groups().into_iter().flatten().flatten())
Box::new(
self.manager
.store()
.groups()
.into_iter()
.flatten()
.flatten(),
)
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/signal/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ use std::path::PathBuf;
use std::pin::Pin;

use async_trait::async_trait;
use presage::libsignal_service::content::Content;
use presage::libsignal_service::models::Contact;
use presage::libsignal_service::prelude::Group;
use presage::prelude::proto::AttachmentPointer;
use presage::prelude::{AttachmentSpec, Contact, Content};
use presage::libsignal_service::sender::AttachmentSpec;
use presage::proto::AttachmentPointer;
use serde::{Deserialize, Serialize};
use tokio::sync::oneshot;
use tokio_stream::Stream;
Expand Down
12 changes: 8 additions & 4 deletions src/signal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ mod manager;
pub mod test;

use anyhow::{bail, Context as _};
use presage::prelude::SignalServers;
use presage_store_sled::{MigrationConflictStrategy, SledStore};
use presage::libsignal_service::configuration::SignalServers;
use presage_store_sled::{MigrationConflictStrategy, OnNewIdentity, SledStore};

use crate::config::{self, Config};

Expand Down Expand Up @@ -36,7 +36,11 @@ pub async fn ensure_linked_device(
.as_ref()
.map(|c| c.signal_db_path.clone())
.unwrap_or_else(config::default_signal_db_path);
let store = SledStore::open(db_path, MigrationConflictStrategy::BackupAndDrop)?;
let store = SledStore::open(
db_path,
MigrationConflictStrategy::BackupAndDrop,
OnNewIdentity::Trust,
)?;

if !relink {
if let Some(config) = config.clone() {
Expand Down Expand Up @@ -84,7 +88,7 @@ pub async fn ensure_linked_device(

// get profile
let phone_number = manager
.state()
.registration_data()
.phone_number
.format()
.mode(phonenumber::Mode::E164)
Expand Down
8 changes: 5 additions & 3 deletions src/signal/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ use std::pin::Pin;
use std::{cell::RefCell, rc::Rc};

use async_trait::async_trait;
use presage::libsignal_service::content::Content;
use presage::libsignal_service::models::Contact;
use presage::libsignal_service::prelude::{AttachmentIdentifier, Group};
use presage::prelude::proto::data_message::Quote;
use presage::prelude::proto::AttachmentPointer;
use presage::prelude::{AttachmentSpec, Contact, Content};
use presage::libsignal_service::sender::AttachmentSpec;
use presage::proto::data_message::Quote;
use presage::proto::AttachmentPointer;
use tokio::sync::oneshot;
use tokio_stream::Stream;
use uuid::Uuid;
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use chrono::{DateTime, Local, NaiveDateTime, TimeZone as _, Utc};
use presage::prelude::PhoneNumber;
use phonenumber::PhoneNumber;
use ratatui::widgets::ListState;
use regex_automata::Regex;
use serde::{Deserialize, Serialize};
Expand Down

0 comments on commit 0278d4c

Please sign in to comment.