Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from jonnius/fix-build
Browse files Browse the repository at this point in the history
Fix build on updated libsignal_service
  • Loading branch information
nanu-c authored Dec 19, 2021
2 parents 6220f94 + ab46cb7 commit f7ca1ce
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
12 changes: 6 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ fn protobuf() -> Result<(), Error> {
Ok(())
}


fn main() {
protobuf().unwrap();
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap();
let output = Command::new("git")
.args(&["rev-parse", "HEAD"])
.output()
.unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash);

Expand All @@ -55,9 +57,7 @@ fn main() {
version
);
} else {
panic!(
"Crayfish requires Rust 1.48.0 or later, but could not determine Rust version.",
);
panic!("Crayfish requires Rust 1.48.0 or later, but could not determine Rust version.");
}
}
let mer_target_root = "";
Expand All @@ -66,6 +66,6 @@ fn main() {

cfg.flag(&format!("--sysroot={}", mer_target_root));
cfg.flag("-isysroot");
cfg.flag(&mer_target_root);
cfg.flag(mer_target_root);
cfg.build("src/main.rs");
}
6 changes: 3 additions & 3 deletions src/service/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ async fn handle_sealed_sender_decrypt(content: &str, queue: Queue) -> Result<Mes
println!("Handle sealed sender decrypt message");

let (tx, rx) = oneshot::channel();

let nested: NestedRequest<sealedsender::SealedSenderMessage> = serde_json::from_str(content)?;
let req = Request::DecryptSealedSender(nested.request.message, tx);
queue.send(req).await?;
let response_data = rx.await??;
Ok(NestedResponse::new_msg(
response_data,
response_data,
CRAYFISH_WEBSOCKET_MESSAGE_SEALED_SENDER_DECRYPT,
))
}
}
4 changes: 2 additions & 2 deletions src/service/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl<T: Serialize> NestedResponse<T> {
fn into_msg(self) -> Message {
Message::text(
serde_json::to_string(&self)
.unwrap_or(ErrorMessage::failure_response(self.response.message_type)),
.unwrap_or_else(|_| ErrorMessage::failure_response(self.response.message_type)),
)
}
}
Expand All @@ -102,7 +102,7 @@ impl ErrorMessage {
pub fn new_msg(error: Error) -> Message {
Message::text(
serde_json::to_string(&ErrorMessage::from(error))
.unwrap_or(Self::failure_response(CRAYFISH_WEBSOCKET_MESSAGE_UNKNOWN)),
.unwrap_or_else(|_| Self::failure_response(CRAYFISH_WEBSOCKET_MESSAGE_UNKNOWN)),
)
}

Expand Down
6 changes: 3 additions & 3 deletions src/signal_service/sealedsender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use crate::store::Storage;
use crate::store::StorageLocation;
extern crate base64;

use libsignal_service::ServiceAddress;
use libsignal_service::cipher::ServiceCipher;
use libsignal_service::configuration::ServiceConfiguration;
use libsignal_service::configuration::SignalServers;
use libsignal_service::prelude::Envelope;
use libsignal_service::ServiceAddress;

use prost::Message;
use libsignal_service::prelude::ProtobufMessage;
// use protocol::envelope::*;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -61,7 +61,7 @@ pub async fn decrypt_sealed_message(
let content_vec = content.body.into_proto().encode_to_vec();
let message = base64::encode(&content_vec);
Ok(DecryptSealedMessageResponse {
message: message,
message,
sender_device: content.metadata.sender_device,
timestamp: content.metadata.timestamp,
needs_receipt: content.metadata.needs_receipt,
Expand Down
11 changes: 5 additions & 6 deletions src/store/protocol_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ impl ProtocolStore {
regid,
})
}

}

impl Storage {
Expand All @@ -76,11 +75,11 @@ impl Storage {

fn identity_path(&self, addr: &ProtocolAddress) -> PathBuf {
let recipient_id = addr_to_path_component(addr.name());
println!("Storage::identity_path", );
println!("Storage::identity_path");
self.path
.join(".storage")
.join("identity")
.join(format!("remote_{}", recipient_id,))
.join(format!("remote_{}", recipient_id))
}

fn prekey_path(&self, id: u32) -> PathBuf {
Expand Down Expand Up @@ -173,7 +172,7 @@ impl protocol::IdentityKeyStore for Storage {
&self,
_: Context,
) -> Result<IdentityKeyPair, SignalProtocolError> {
println!("Storage::get_identity_key_pair", );
println!("Storage::get_identity_key_pair");

println!("identity_key_pair");
let protocol_store = self.protocol_store.read().await;
Expand Down Expand Up @@ -239,7 +238,7 @@ impl protocol::IdentityKeyStore for Storage {
addr: &ProtocolAddress,
_: Context,
) -> Result<Option<IdentityKey>, SignalProtocolError> {
println!("Storage::get_identity", );
println!("Storage::get_identity");

let _lock = self.protocol_store.read().await;

Expand Down Expand Up @@ -534,7 +533,7 @@ impl Storage {
addr: &ProtocolAddress,
) -> Result<Option<IdentityKey>, SignalProtocolError> {
let path = self.identity_path(addr);
println!("Storage::read_identity_key_file", );
println!("Storage::read_identity_key_file");
if path.is_file() {
let buf = load_file(self.keys, path).await.expect("read identity key");
match buf.len() {
Expand Down

0 comments on commit f7ca1ce

Please sign in to comment.