diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8683740e9..9333b6daa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,7 +49,6 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable - rustflags: '' - name: Check out code uses: actions/checkout@v4 @@ -158,7 +157,6 @@ jobs: with: toolchain: stable target: aarch64-unknown-linux-gnu - rustflags: '' - name: Setup C compiler, linker and pkgconfig run: | @@ -252,7 +250,7 @@ jobs: - name: Build click (${{ matrix.arch }}) # workaround https://github.com/actions/runner/issues/1479#issuecomment-969306629 - uses: ChristopherHX/conditional@b4a9649204f81002ec9a4ef7d4bf7d6b2ab7fa55 + uses: ChristopherHX/conditional@01004426dfbc58dc9bfe0713f146f1429eb5025e # main with: step: | uses: docker://clickable/ci-20.04-${{ matrix.arch }}:8.2.0 diff --git a/Cargo.toml b/Cargo.toml index 4aaa4fd6d..bbf5161bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,10 +5,7 @@ edition = "2021" description = """\ This is a cross-platform Signal client.""" license = "GPL-3" -rust = "1.71" - -[source.crates-io] -registry = "git://github.com/rust-lang/crates.io-index.git" +rust-version = "1.75" [build-dependencies] tauri-build = { version = "2.0.0-rc.6", features = [], optional = true } diff --git a/src/handlers.rs b/src/handlers.rs index f5e90c2d0..6f2661dd9 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -231,7 +231,6 @@ impl Handler { log::error!("Too many errors, exiting or sender is none {:?}", count); // Exit this loop exit(0); - break; } count += 1; @@ -838,24 +837,6 @@ impl Handler { Ok(()) } - async fn thread_metadata( - &self, - thread: &Thread, - ) -> Result, ApplicationError> { - let manager = match self.manager_thread.get() { - Some(m) => m, - None => { - log::error!("Manager not initialized"); - return Err(ApplicationError::RegistrationError( - "Manager not initialized".to_string(), - )); - } - }; - match manager.thread_metadata(thread).await { - Ok(metadata) => Ok(metadata), - Err(e) => Err(ApplicationError::from(e)), - } - } // update_contact_name updates the name of a contact and also updates the thread metadata title async fn update_contact_name( &self, @@ -1342,67 +1323,58 @@ impl Handler { let thread_metadata = manager.thread_metadata(&thread).await.unwrap(); if thread_metadata.is_none() { self.create_thread_metadata(&thread).await.unwrap(); - match thread { - Thread::Contact(uuid) => { - let contact = match manager.get_contact_by_id(uuid).await.unwrap() { - Some(c) => c, - None => { - log::error!("handle_get_message_list: Contact not found"); - return Err(ApplicationError::InvalidRequest); - } - }; - match self.update_contact_name(contact).await { - Ok(_) => (), - Err(e) => { - log::error!( - "handle_get_message_list: Error updating contact name: {}", - e - ); - } + if let Thread::Contact(uuid) = thread { + let contact = match manager.get_contact_by_id(uuid).await.unwrap() { + Some(c) => c, + None => { + log::error!("handle_get_message_list: Contact not found"); + return Err(ApplicationError::InvalidRequest); + } + }; + match self.update_contact_name(contact).await { + Ok(_) => (), + Err(e) => { + log::error!( + "handle_get_message_list: Error updating contact name: {}", + e + ); } } - _ => (), } } else { let mut thread_metadata = thread_metadata.unwrap(); match thread_metadata.title.clone() { Some(title) => { // check if title is a valid uuid - match thread { - Thread::Contact(uuid) => { - if Uuid::parse_str(&title).is_ok() || title.is_empty() { - let mut contact = - match manager.get_contact_by_id(uuid).await.unwrap() { - Some(c) => c, - None => { - log::error!( - "handle_get_message_list: Contact not found" - ); - return Err(ApplicationError::InvalidRequest); - } - }; - contact = match self.update_contact_name(contact).await { - Ok(c) => c.unwrap(), - Err(e) => { - log::error!("Error updating contact name: {}", e); + if let Thread::Contact(uuid) = thread { + if Uuid::parse_str(&title).is_ok() || title.is_empty() { + let contact = match manager.get_contact_by_id(uuid).await.unwrap() { + Some(c) => c, + None => { + log::error!("handle_get_message_list: Contact not found"); + return Err(ApplicationError::InvalidRequest); + } + }; + _ = match self.update_contact_name(contact).await { + Ok(c) => c.unwrap(), + Err(e) => { + log::error!("Error updating contact name: {}", e); + return Err(ApplicationError::InvalidRequest); + } + }; + + // retrieve updated thread metadata + thread_metadata = + match manager.thread_metadata(&thread).await.unwrap() { + Some(tm) => tm, + None => { + log::error!( + "handle_get_message_list: Thread metadata not found" + ); return Err(ApplicationError::InvalidRequest); } }; - - // retrieve updated thread metadata - thread_metadata = - match manager.thread_metadata(&thread).await.unwrap() { - Some(tm) => tm, - None => { - log::error!( - "handle_get_message_list: Thread metadata not found" - ); - return Err(ApplicationError::InvalidRequest); - } - }; - } } - _ => (), } } @@ -1613,32 +1585,27 @@ impl Handler { } let mut response_data = thread_metadata.unwrap(); - match response_data.thread { - Thread::Contact(uuid) => { - if response_data.title.is_none() || response_data.title.clone().unwrap().len() == 36 - { - log::debug!("Updating contact from profile {:?}", uuid); - let contact = match manager.get_contact_by_id(uuid).await.unwrap() { - Some(c) => c, - None => { - log::error!("No contact found"); - return Err(ApplicationError::RegistrationError( - "No contact found".to_string(), - )); - } - }; - match self.update_contact_name(contact).await { - Ok(_) => { - response_data = - manager.thread_metadata(&thread).await.unwrap().unwrap(); - } - Err(e) => { - log::error!("Error updating contact name: {}", e); - } + if let Thread::Contact(uuid) = response_data.thread { + if response_data.title.is_none() || response_data.title.clone().unwrap().len() == 36 { + log::debug!("Updating contact from profile {:?}", uuid); + let contact = match manager.get_contact_by_id(uuid).await.unwrap() { + Some(c) => c, + None => { + log::error!("No contact found"); + return Err(ApplicationError::RegistrationError( + "No contact found".to_string(), + )); + } + }; + match self.update_contact_name(contact).await { + Ok(_) => { + response_data = manager.thread_metadata(&thread).await.unwrap().unwrap(); + } + Err(e) => { + log::error!("Error updating contact name: {}", e); } } } - _ => {} } let response = AxolotlResponse { @@ -1662,8 +1629,8 @@ impl Handler { ) -> Result, ApplicationError> { log::info!("Getting config"); // let my_uuid = manager.uuid(); - let mut platform = "".to_string(); - platform = "linux".to_string(); + #[allow(unused_mut, unused_assignments)] + let mut platform = "linux".to_string(); #[cfg(target_os = "windows")] { platform = "windows".to_string(); @@ -1680,9 +1647,9 @@ impl Handler { { platform = "ios".to_string(); } - let mut feature = "".to_string(); - feature = "desktop".to_string(); + #[allow(unused_mut, unused_assignments)] + let mut feature = "desktop".to_string(); #[cfg(feature = "tauri")] { feature = "tauri".to_string(); @@ -1762,17 +1729,7 @@ impl Handler { } else { "Invalid message" }; - struct Wrapper(Cell>); - impl Serialize for Wrapper - where - I: IntoIterator, - P: Serialize, - { - fn serialize(&self, s: S) -> Result { - s.collect_seq(self.0.take().unwrap()) - } - } // Check the type of request if let Ok::(axolotl_request) = serde_json::from_str(msg) { // Axolotl request diff --git a/src/messages.rs b/src/messages.rs index f5cefff51..54ba523d3 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -5,6 +5,7 @@ use crate::manager_thread::ManagerThread; use crate::requests::{AxolotlMessage, AxolotlResponse, SendMessageResponse}; use presage::prelude::*; use presage::proto::{DataMessage, GroupContextV2}; +use presage::store::ContentsStore; use presage::{Manager, Thread}; use presage_store_sled::SledStore; use std::time::UNIX_EPOCH; @@ -123,7 +124,7 @@ pub async fn send_message_to_group( ..Default::default() }; - match manager.group(&master_key) { + match manager.store().group(master_key) { Ok(group) => match group { Some(_) => { manager