Skip to content
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
10 changes: 5 additions & 5 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<wacore::iq::privacy::PrivacySettingsResponse, crate::request::IqError> {
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> {
Expand Down Expand Up @@ -1496,7 +1498,6 @@ impl Client {
Ok(())
}

#[allow(dead_code)]
async fn request_app_state_keys(&self, raw_key_ids: &[Vec<u8>]) {
if raw_key_ids.is_empty() {
return;
Expand Down Expand Up @@ -1536,7 +1537,6 @@ impl Client {
}
}

#[allow(dead_code)]
async fn dispatch_app_state_mutation(
&self,
m: &crate::appstate_sync::Mutation,
Expand Down Expand Up @@ -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?;

Expand Down
4 changes: 2 additions & 2 deletions src/client/lid_pn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 mappinguse original JID. Mapping will be learned
// organically from incoming messages or usync responses.
resolved.push(jid.clone());
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/handlers/unimplemented.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 0 additions & 4 deletions src/lid_pn_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -153,9 +152,6 @@ impl LidPnCache {
}
}

/// Thread-safe shared reference to the LID-PN cache
pub type SharedLidPnCache = Arc<LidPnCache>;

#[cfg(test)]
mod tests {
use super::*;
Expand Down
5 changes: 1 addition & 4 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -215,12 +214,10 @@ impl Default for SessionManager {
}
}

/// Thread-safe reference to a SessionManager
pub type SharedSessionManager = Arc<SessionManager>;

#[cfg(test)]
mod tests {
use super::*;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::time::Duration;

Expand Down
2 changes: 0 additions & 2 deletions wacore/libsignal/src/protocol/storage/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<()>;

Expand Down
30 changes: 1 addition & 29 deletions wacore/src/client.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
Expand Down
61 changes: 0 additions & 61 deletions wacore/src/iq/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,43 +60,6 @@ pub fn optional_jid(node: &Node, key: &str) -> Result<Option<Jid>, 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 `<error>` child to indicate the data is unavailable.
pub fn optional_string_content(node: &Node, child_tag: &str) -> Option<String> {
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: `<lid val="123@lid"/>` -> returns parsed JID
pub fn optional_jid_from_child(node: &Node, child_tag: &str, attr: &str) -> Option<Jid> {
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<String> {
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.
Expand All @@ -110,27 +73,3 @@ pub fn collect_children<T: ProtocolNode>(node: &Node, tag: &str) -> Result<Vec<T
.map(|child| T::try_from_node(child))
.collect()
}

/// Parse all children with a given tag into a Vec of ProtocolNodes, skipping parse errors.
///
/// Logs a warning for each child that fails to parse.
///
/// # Example
/// ```ignore
/// let entries = collect_children_lenient::<BlocklistEntry>(node, "item");
/// ```
pub fn collect_children_lenient<T: ProtocolNode>(node: &Node, tag: &str) -> Vec<T> {
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()
}
1 change: 0 additions & 1 deletion wacore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions wacore/src/proto_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <group> node).
false
}
}
Expand Down
47 changes: 0 additions & 47 deletions wacore/src/runtime.rs

This file was deleted.

Loading