From a5e63dcdfd25c70aa42d83d91c9e88195e34cd8c Mon Sep 17 00:00:00 2001 From: Alex Emmet <111742636+Alex-Emmet@users.noreply.github.com> Date: Tue, 25 Nov 2025 08:10:14 +0100 Subject: [PATCH] Completed Calling Structure (Needs testing) --- src/rho/iota_connection.rs | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/rho/iota_connection.rs b/src/rho/iota_connection.rs index b7eb7fb..e160e48 100644 --- a/src/rho/iota_connection.rs +++ b/src/rho/iota_connection.rs @@ -7,14 +7,12 @@ use async_tungstenite::WebSocketReceiver; use async_tungstenite::WebSocketSender; use async_tungstenite::tungstenite::Message; use json::JsonValue; -use json::parse; use std::{ collections::HashMap, sync::{Arc, Weak}, }; use tokio::sync::RwLock; use tokio_util::compat::Compat; -use tower::retry::backoff::InvalidBackoff; use tungstenite::Utf8Bytes; use uuid::Uuid; @@ -285,36 +283,37 @@ impl IotaConnection { let mut interested_ids: Vec = Vec::new(); let calls: Vec> = call_manager::get_call_groups(receiver_id).await; - let mut invites: HashMap> = HashMap::new(); + let mut invites: HashMap> = HashMap::new(); for call in calls { for inviter in call.members.read().await.iter() { let inviter_id = inviter.user_id; if let Some(call_ids) = invites.get_mut(&inviter_id) { - call_ids.push(call.call_id); + call_ids.push(JsonValue::String(call.call_id.to_string())); } else { - invites.insert(inviter_id, vec![call.call_id]); + invites.insert( + inviter_id, + vec![JsonValue::String(call.call_id.to_string())], + ); } } } // Process contacts and add call information - // Enriched Contacts data: - // [{"user_id": "uuid", "calls": ["call_id"]}, {"user_id": "uuid"}] let mut enriched_contacts = JsonValue::new_array(); - // Contacts data: - // [{"user_id": "uuid"}, {"user_id": "uuid"}] if let Some(contacts_data) = cv.get_data(DataTypes::user_ids) { if let JsonValue::Array(user_ids) = contacts_data { - for user_id in user_ids { - if let JsonValue::String(user_id_str) = user_id { - if let Ok(user_id) = Uuid::parse_str(user_id_str) { - interested_ids.push(user_id); - let mut enriched_contact = JsonValue::new_object(); - let _ = enriched_contact.insert("user_id", user_id.to_string()); - let _ = enriched_contact.insert("calls", JsonValue::new_array()); - let _ = enriched_contacts.push(enriched_contact); - } + for user_json in user_ids { + let user_id_str = user_json["user_id"].as_str().unwrap_or(""); + if let Ok(user_id) = Uuid::parse_str(&user_id_str) { + interested_ids.push(user_id); + let mut enriched_contact = JsonValue::new_object(); + let _ = enriched_contact.insert("user_id", user_id.to_string()); + let _ = enriched_contact.insert( + "calls", + JsonValue::Array(invites.get(&user_id).unwrap_or(&vec![]).clone()), + ); + let _ = enriched_contacts.push(enriched_contact); } } } else {