diff --git a/src/client.rs b/src/client.rs index 91961535e..8cedb8723 100644 --- a/src/client.rs +++ b/src/client.rs @@ -997,12 +997,14 @@ impl Client { Ok(()) } - pub async fn fetch_privacy_settings(&self) -> Result<(), crate::request::IqError> { + pub async fn fetch_privacy_settings( + &self, + ) -> Result { use wacore::iq::privacy::PrivacySettingsSpec; debug!("Fetching privacy settings..."); - self.execute(PrivacySettingsSpec::new()).await.map(|_| ()) + self.execute(PrivacySettingsSpec::new()).await } pub async fn send_digest_key_bundle(&self) -> Result<(), crate::request::IqError> { @@ -1496,7 +1498,6 @@ impl Client { Ok(()) } - #[allow(dead_code)] async fn request_app_state_keys(&self, raw_key_ids: &[Vec]) { if raw_key_ids.is_empty() { return; @@ -1536,7 +1537,6 @@ impl Client { } } - #[allow(dead_code)] async fn dispatch_app_state_mutation( &self, m: &crate::appstate_sync::Mutation, @@ -1981,7 +1981,7 @@ impl Client { false, false, Some(crate::types::message::EditAttribute::MessageEdit), - vec![], // TODO: Support extra nodes for edit messages if needed + vec![], ) .await?; diff --git a/src/client/lid_pn.rs b/src/client/lid_pn.rs index 53a5cf7e6..88ee0914f 100644 --- a/src/client/lid_pn.rs +++ b/src/client/lid_pn.rs @@ -118,8 +118,8 @@ impl Client { if let Some(lid_user) = self.lid_pn_cache.get_current_lid(&jid.user).await { resolved.push(Jid::lid_device(lid_user, jid.device)); } else { - // No cached mapping, use original JID - // TODO: Could trigger usync query here for proactive resolution + // No cached mapping — use original JID. Mapping will be learned + // organically from incoming messages or usync responses. resolved.push(jid.clone()); } } diff --git a/src/handlers/unimplemented.rs b/src/handlers/unimplemented.rs index cd4dd08f6..4ce3f96b5 100644 --- a/src/handlers/unimplemented.rs +++ b/src/handlers/unimplemented.rs @@ -28,10 +28,6 @@ impl UnimplementedHandler { pub fn for_presence() -> Self { Self::new(vec!["presence"]) } - - pub fn for_chatstate() -> Self { - Self::new(vec!["chatstate"]) - } } #[async_trait] diff --git a/src/lib.rs b/src/lib.rs index 4d4b86977..1549f1993 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -pub use wacore::{proto_helpers, store::traits}; +pub use wacore::{iq::privacy as privacy_settings, proto_helpers, store::traits}; pub use wacore_binary::builder::NodeBuilder; pub use wacore_binary::jid::Jid; pub use waproto; diff --git a/src/lid_pn_cache.rs b/src/lid_pn_cache.rs index b022083b0..95bc20ec0 100644 --- a/src/lid_pn_cache.rs +++ b/src/lid_pn_cache.rs @@ -12,7 +12,6 @@ //! (by `created_at` timestamp) is considered "current". use std::collections::HashMap; -use std::sync::Arc; use tokio::sync::RwLock; pub use wacore::types::{LearningSource, LidPnEntry}; @@ -153,9 +152,6 @@ impl LidPnCache { } } -/// Thread-safe shared reference to the LID-PN cache -pub type SharedLidPnCache = Arc; - #[cfg(test)] mod tests { use super::*; diff --git a/src/session.rs b/src/session.rs index 9129d59e6..6ec42ddc8 100644 --- a/src/session.rs +++ b/src/session.rs @@ -9,7 +9,6 @@ //! recipient from multiple concurrent operations. use std::collections::{HashMap, HashSet}; -use std::sync::Arc; use tokio::sync::{Mutex, oneshot}; use wacore_binary::jid::Jid; @@ -215,12 +214,10 @@ impl Default for SessionManager { } } -/// Thread-safe reference to a SessionManager -pub type SharedSessionManager = Arc; - #[cfg(test)] mod tests { use super::*; + use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use std::time::Duration; diff --git a/wacore/libsignal/src/protocol/storage/traits.rs b/wacore/libsignal/src/protocol/storage/traits.rs index 7764df8c6..6d7747ac1 100644 --- a/wacore/libsignal/src/protocol/storage/traits.rs +++ b/wacore/libsignal/src/protocol/storage/traits.rs @@ -13,7 +13,6 @@ use crate::protocol::state::{ use crate::protocol::{IdentityKey, IdentityKeyPair, ProtocolAddress}; use crate::store::sender_key_name::SenderKeyName; -// TODO: consider moving this enum into utils.rs? /// Each Signal message can be considered to have exactly two participants, a sender and receiver. /// /// [IdentityKeyStore::is_trusted_identity] uses this to ensure the identity provided is configured @@ -150,7 +149,6 @@ pub trait SenderKeyStore: ThreadSafe { async fn store_sender_key( &mut self, sender_key_name: &SenderKeyName, - // TODO: pass this by value! record: &SenderKeyRecord, ) -> Result<()>; diff --git a/wacore/src/client.rs b/wacore/src/client.rs index 4215a7921..a9692d9a2 100644 --- a/wacore/src/client.rs +++ b/wacore/src/client.rs @@ -1,7 +1,7 @@ pub mod context; use crate::store::Device; -use crate::{runtime::ProcessResult, types::events::CoreEventBus}; +use crate::types::events::CoreEventBus; /// Core client containing only platform-independent protocol logic pub struct CoreClient { @@ -19,34 +19,6 @@ impl CoreClient { } } - /// Processes an incoming message/event and returns the result - /// This is a pure function that doesn't perform any I/O - pub fn process_incoming_data(&self, _data: &[u8]) -> ProcessResult { - // TODO: Implement core message processing logic - // This would include: - // - Binary protocol parsing - // - Message decryption - // - Event generation - // But without any I/O operations - - ProcessResult::new() - } - - /// Prepares outgoing data for sending - /// This is a pure function that doesn't perform any I/O - pub fn prepare_outgoing_message( - &self, - _message: &str, // placeholder - ) -> ProcessResult { - // TODO: Implement core message preparation logic - // This would include: - // - Message encryption - // - Binary protocol encoding - // But without any network operations - - ProcessResult::new() - } - /// Gets the current device state pub fn get_device(&self) -> &Device { &self.device diff --git a/wacore/src/iq/node.rs b/wacore/src/iq/node.rs index aaa79bd1c..90652f817 100644 --- a/wacore/src/iq/node.rs +++ b/wacore/src/iq/node.rs @@ -60,43 +60,6 @@ pub fn optional_jid(node: &Node, key: &str) -> Result, anyhow::Error Ok(node.attrs().optional_jid(key)) } -/// Get optional string content from a child node, skipping if an error child exists. -/// -/// This is a common pattern in usync responses where a node may contain -/// an `` child to indicate the data is unavailable. -pub fn optional_string_content(node: &Node, child_tag: &str) -> Option { - use wacore_binary::node::NodeContent; - - node.get_optional_child(child_tag).and_then(|child| { - if child.get_optional_child("error").is_some() { - return None; - } - match &child.content { - Some(NodeContent::String(s)) if !s.is_empty() => Some(s.clone()), - _ => None, - } - }) -} - -/// Get optional JID from a child node's attribute (commonly "val"). -/// -/// Example: `` -> returns parsed JID -pub fn optional_jid_from_child(node: &Node, child_tag: &str, attr: &str) -> Option { - node.get_optional_child(child_tag) - .and_then(|n| n.attrs().optional_string(attr)) - .and_then(|s| s.parse().ok()) -} - -/// Get optional string attribute from a child node, skipping if an error child exists. -pub fn optional_attr_skipping_error(node: &Node, child_tag: &str, attr: &str) -> Option { - node.get_optional_child(child_tag).and_then(|child| { - if child.get_optional_child("error").is_some() { - return None; - } - child.attrs().optional_string(attr).map(|s| s.to_string()) - }) -} - /// Parse all children with a given tag into a Vec of ProtocolNodes. /// /// Returns an error if any child fails to parse. @@ -110,27 +73,3 @@ pub fn collect_children(node: &Node, tag: &str) -> Result(node, "item"); -/// ``` -pub fn collect_children_lenient(node: &Node, tag: &str) -> Vec { - node.get_children_by_tag(tag) - .filter_map(|child| match T::try_from_node(child) { - Ok(item) => Some(item), - Err(e) => { - log::warn!( - target: "iq::node", - "Failed to parse <{}>: {e}", - tag - ); - None - } - }) - .collect() -} diff --git a/wacore/src/lib.rs b/wacore/src/lib.rs index 5db7d2f29..b4b3aa9c7 100644 --- a/wacore/src/lib.rs +++ b/wacore/src/lib.rs @@ -25,7 +25,6 @@ pub mod prekeys; pub mod proto_helpers; pub mod reporting_token; pub mod request; -pub mod runtime; pub mod send; pub mod stanza; pub mod store; diff --git a/wacore/src/proto_helpers.rs b/wacore/src/proto_helpers.rs index 86e0b5b36..fcb337cda 100644 --- a/wacore/src/proto_helpers.rs +++ b/wacore/src/proto_helpers.rs @@ -424,12 +424,13 @@ impl ConversationExt for wa::Conversation { } fn is_locked(&self) -> bool { - // TODO: derive from SyncActionValue in GroupInfoUpdate. - false + self.locked.unwrap_or(false) } fn is_announce_only(&self) -> bool { - // TODO: derive from SyncActionValue in GroupInfoUpdate. + // The Conversation proto does not carry an `announce` field. + // Announce mode is only available from the group metadata IQ + // response (restrict/announce attributes on the node). false } } diff --git a/wacore/src/runtime.rs b/wacore/src/runtime.rs deleted file mode 100644 index 278adc327..000000000 --- a/wacore/src/runtime.rs +++ /dev/null @@ -1,47 +0,0 @@ -use async_trait::async_trait; -use wacore_binary::node::Node; - -/// Trait for sending data over the network. -/// The driver implementation will handle the actual I/O operations. -#[async_trait] -pub trait NetworkTransport: Send + Sync { - /// Send a node over the network - async fn send_node(&self, node: Node) -> Result<(), anyhow::Error>; - - /// Wait for a response to an IQ with the given ID - async fn wait_for_response( - &self, - id: &str, - timeout: std::time::Duration, - ) -> Result; -} - -/// Result type for core processing operations -#[derive(Debug)] -pub struct ProcessResult { - pub nodes_to_send: Vec, -} - -impl ProcessResult { - pub fn new() -> Self { - Self { - nodes_to_send: Vec::new(), - } - } - - pub fn with_node(mut self, node: Node) -> Self { - self.nodes_to_send.push(node); - self - } - - pub fn with_nodes(mut self, nodes: Vec) -> Self { - self.nodes_to_send.extend(nodes); - self - } -} - -impl Default for ProcessResult { - fn default() -> Self { - Self::new() - } -} diff --git a/wacore/src/types/events.rs b/wacore/src/types/events.rs index 22a8f466e..1d292766a 100644 --- a/wacore/src/types/events.rs +++ b/wacore/src/types/events.rs @@ -1,8 +1,6 @@ use crate::stanza::BusinessSubscription; use crate::types::message::MessageInfo; -use crate::types::newsletter::{NewsletterMetadata, NewsletterMuteState, NewsletterRole}; use crate::types::presence::{ChatPresence, ChatPresenceMedia, ReceiptType}; -use crate::types::user::PrivacySettings; use bytes::Bytes; use chrono::{DateTime, Duration, Utc}; use prost::Message; @@ -96,16 +94,6 @@ impl LazyConversation { conv }) } - - /// Returns true if the conversation has been parsed. - pub fn is_parsed(&self) -> bool { - self.parsed.get().is_some() - } - - /// Get the raw bytes size (useful for debugging/metrics). - pub fn raw_size(&self) -> usize { - self.raw_bytes.len() - } } impl fmt::Debug for LazyConversation { @@ -388,15 +376,6 @@ pub struct ClientOutdated; #[derive(Debug, Clone, Serialize)] pub struct Connected; -#[derive(Debug, Clone, Serialize)] -pub struct KeepAliveTimeout { - pub error_count: i32, - pub last_success: DateTime, -} - -#[derive(Debug, Clone, Serialize)] -pub struct KeepAliveRestored; - #[derive(Debug, Clone, Serialize)] pub struct LoggedOut { pub on_connect: bool, @@ -406,9 +385,6 @@ pub struct LoggedOut { #[derive(Debug, Clone, Serialize)] pub struct StreamReplaced; -#[derive(Debug, Clone, Serialize)] -pub struct ManualLoginReconnect; - #[derive(Debug, Clone, PartialEq, Eq, Serialize)] pub enum TempBanReason { SentToTooManyPeople, @@ -551,11 +527,6 @@ pub struct ConnectFailure { pub raw: Option, } -#[derive(Debug, Clone, Serialize)] -pub struct CatRefreshError { - pub error: String, -} - #[derive(Debug, Clone, Serialize)] pub struct StreamError { pub code: String, @@ -637,18 +608,6 @@ pub struct UserAboutUpdate { pub timestamp: DateTime, } -#[derive(Debug, Clone, Serialize)] -pub struct IdentityChange { - pub jid: Jid, - pub timestamp: DateTime, - pub implicit: bool, -} - -#[derive(Debug, Clone, Serialize)] -pub struct PrivacySettingsUpdate { - pub new_settings: PrivacySettings, -} - #[derive(Debug, Clone, Serialize)] pub struct ContactUpdate { pub jid: Jid, @@ -673,17 +632,6 @@ pub struct PinUpdate { pub from_full_sync: bool, } -#[derive(Debug, Clone, Serialize)] -pub struct StarUpdate { - pub chat_jid: Jid, - pub sender_jid: Option, - pub is_from_me: bool, - pub message_id: MessageId, - pub timestamp: DateTime, - pub action: Box, - pub from_full_sync: bool, -} - #[derive(Debug, Clone, Serialize)] pub struct MuteUpdate { pub jid: Jid, @@ -707,27 +655,3 @@ pub struct MarkChatAsReadUpdate { pub action: Box, pub from_full_sync: bool, } - -#[derive(Debug, Clone, Serialize)] -pub struct NewsletterJoin { - pub metadata: NewsletterMetadata, -} - -#[derive(Debug, Clone, Serialize)] -pub struct NewsletterLeave { - pub id: Jid, - pub role: NewsletterRole, -} - -#[derive(Debug, Clone, Serialize)] -pub struct NewsletterMuteChange { - pub id: Jid, - pub mute: NewsletterMuteState, -} - -#[derive(Debug, Clone, Serialize)] -pub struct NewsletterLiveUpdate { - pub jid: Jid, - pub time: DateTime, - pub messages: Vec, -} diff --git a/wacore/src/types/mod.rs b/wacore/src/types/mod.rs index 5f53c30d6..b58a09e02 100644 --- a/wacore/src/types/mod.rs +++ b/wacore/src/types/mod.rs @@ -3,7 +3,6 @@ pub mod events; pub mod jid; pub mod lid_pn; pub mod message; -pub mod newsletter; pub mod presence; pub mod spam_report; pub mod user;