Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add libsignal-service/presage linking fix #299

Merged
merged 6 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 20 additions & 29 deletions Cargo.lock

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

10 changes: 5 additions & 5 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 = "f93f2de" }
presage-store-sled = { git = "https://github.com/whisperfish/presage", rev = "f93f2de" }
presage = { git = "https://github.com/whisperfish/presage", rev = "e2392c42a0392397b9db782607fdd7ab2ea91b5f" }
presage-store-sled = { git = "https://github.com/whisperfish/presage", rev = "e2392c42a0392397b9db782607fdd7ab2ea91b5f" }

# dev feature dependencies
prost = { version = "0.12.0", optional = true }
Expand All @@ -56,7 +56,7 @@ mime_guess = "2.0.4"
notify-rust = "4.5.10"
once_cell = "1.18.0"
opener = "0.7.0"
phonenumber = "0.3.1"
phonenumber = "0.3.6"
postcard = { version = "1.0.4", features = ["alloc"] }
qr2term = { git = "https://github.com/boxdot/qr2term-rs", rev = "ed8ae7f" }
ratatui = "0.26.0"
Expand Down Expand Up @@ -92,7 +92,7 @@ quickcheck_macros = "1.0.0"
name = "app"
harness = false

[patch."https://github.com/whisperfish/presage.git"]
# [patch."https://github.com/whisperfish/presage.git"]
# presage = { path = "../presage/presage" }
# presage-store-sled = { path = "../presage/presage-store-sled" }
#
Expand All @@ -103,4 +103,4 @@ harness = false
[patch.crates-io]
# signal-protocol uses a fork of this library via the patch mechanism of cargo.
# Since it is not transitive, we have to add the patch here explicitly.
"curve25519-dalek" = { git = 'https://github.com/signalapp/curve25519-dalek', tag = 'signal-curve25519-4.1.1' }
"curve25519-dalek" = { git = 'https://github.com/signalapp/curve25519-dalek', tag = 'signal-curve25519-4.1.3' }
18 changes: 17 additions & 1 deletion src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::io::BufWriter;

use base64::prelude::*;
use presage::libsignal_service::content::{Content, Metadata};
use presage::libsignal_service::ServiceAddress;
use presage::libsignal_service::{ServiceAddress, ServiceIdType};
use presage::proto;
use prost::Message;
use serde::{Deserialize, Serialize};
Expand All @@ -19,6 +19,7 @@ pub struct ContentBase64 {
#[derive(Serialize, Deserialize)]
#[serde(remote = "Metadata")]
struct MetadataDef {
#[serde(with = "ServiceAddressDef")]
sender: ServiceAddress,
sender_device: u32,
timestamp: u64,
Expand All @@ -27,6 +28,21 @@ struct MetadataDef {
server_guid: Option<Uuid>,
}

#[derive(Serialize, Deserialize)]
#[serde(remote = "ServiceAddress")]
struct ServiceAddressDef {
pub uuid: Uuid,
#[serde(with = "ServiceIdTypeDef")]
pub identity: ServiceIdType,
}

#[derive(Serialize, Deserialize)]
#[serde(remote = "ServiceIdType")]
pub enum ServiceIdTypeDef {
AccountIdentity,
PhoneNumberIdentity,
}

impl From<Metadata> for MetadataDef {
fn from(metadata: Metadata) -> Self {
Self {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async fn main() -> anyhow::Result<()> {
let _guard = if args.verbosity > 0 {
let file_appender = tracing_appender::rolling::never("./", "gurk.log");
let (non_blocking, guard) = tracing_appender::non_blocking(file_appender);
tracing_subscriber::fmt()
tracing_subscriber::fmt::fmt()
.with_max_level(match args.verbosity {
0 => LevelFilter::OFF,
1 => LevelFilter::INFO,
Expand Down
2 changes: 2 additions & 0 deletions src/signal/attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fn derive_name(pointer: &AttachmentPointer, digest: &[u8], mime: &Mime) -> Strin
#[cfg(test)]
mod tests {
use hex_literal::hex;
use uuid::Uuid;

use super::*;

Expand All @@ -110,6 +111,7 @@ mod tests {
upload_timestamp: u64,
) -> AttachmentPointer {
AttachmentPointer {
uuid: Some(Uuid::nil().into_bytes().to_vec()),
content_type: Some(content_type.into()),
digest: Some(digest.into()),
file_name: file_name.map(|s| s.to_owned()),
Expand Down
16 changes: 13 additions & 3 deletions src/signal/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use presage::libsignal_service::content::{Content, ContentBody};
use presage::libsignal_service::models::Contact;
use presage::libsignal_service::prelude::{Group, ProfileKey};
use presage::libsignal_service::sender::AttachmentSpec;
use presage::libsignal_service::ServiceAddress;
use presage::manager::{ReceivingMode, Registered};
use presage::proto::data_message::{Quote, Reaction};
use presage::proto::{AttachmentPointer, DataMessage, GroupContextV2, ReceiptMessage};
Expand Down Expand Up @@ -98,7 +99,10 @@ impl SignalManager for PresageManager {
let mut manager = self.manager.clone();
tokio::task::spawn_local(async move {
let body = ContentBody::ReceiptMessage(data_message);
if let Err(error) = manager.send_message(sender_uuid, body, now_timestamp).await {
if let Err(error) = manager
.send_message(ServiceAddress::new_aci(sender_uuid), body, now_timestamp)
.await
{
error!(%error, %sender_uuid, "failed to send receipt");
}
});
Expand Down Expand Up @@ -162,7 +166,10 @@ impl SignalManager for PresageManager {
return;
}
let body = ContentBody::DataMessage(data_message);
if let Err(error) = manager.send_message(uuid, body, timestamp).await {
if let Err(error) = manager
.send_message(ServiceAddress::new_aci(uuid), body, timestamp)
.await
{
error!(dest =% uuid, %error, "failed to send message");
let _ = response_tx.send(Err(error.into()));
return;
Expand Down Expand Up @@ -241,7 +248,10 @@ impl SignalManager for PresageManager {
let mut manager = self.manager.clone();
let body = ContentBody::DataMessage(data_message);
tokio::task::spawn_local(async move {
if let Err(e) = manager.send_message(uuid, body, timestamp).await {
if let Err(e) = manager
.send_message(ServiceAddress::new_aci(uuid), body, timestamp)
.await
{
// TODO: Proper error handling
error!("failed to send reaction {} to {}: {}", &emoji, uuid, e);
}
Expand Down