[Fix] Add chats, propper rho selection

This commit is contained in:
Alex Emmet 2026-03-27 00:26:37 +01:00
commit 05006980f7
5 changed files with 36 additions and 16 deletions

View file

@ -469,10 +469,31 @@ impl OmegaConnection {
let msg_id = cv.get_id();
if let Some((_, task)) = WAITING_TASKS.remove(&msg_id) {
if (task.task)(self.clone(), cv) {
if (task.task)(self.clone(), cv.clone()) {
continue;
}
}
if cv.is_type(CommunicationType::iota_user_data) {
if let DataValue::Array(users) = cv.get_data(DataTypes::user_ids) {
let mut user_ids: Vec<u64> = Vec::new();
for value in users {
if let DataValue::Number(user_id) = value {
user_ids.push(*user_id as u64);
}
}
let connections = crate::rho::rho_manager::RHO_CONNECTIONS.read().await;
if let Some(iota_id) = cv.get_data(DataTypes::iota_id).as_number() {
if let Some(rho) = connections.get(&iota_id) {
rho.get_iota_connection().set_user_ids(user_ids).await;
}
} else {
for rho in connections.values() {
rho.get_iota_connection().set_user_ids(user_ids.clone()).await;
}
}
}
}
}
Err(e) => {
log_err!(0, PrintType::Omega, "Receive error: {}", e);

View file

@ -412,7 +412,7 @@ impl ClientConnection {
&& cv
.get_data(DataTypes::chat_partner_id)
.as_number()
.is_some()
.is_none()
{
let chat_partner_name = cv
.get_data(DataTypes::chat_partner_name)

View file

@ -270,6 +270,9 @@ impl GeneralConnection {
let user_id = id as i64;
let client = ClientConnection::from_general(self.clone(), id).await;
client.clone().start();
let mut rho = rho_manager::get_rho_con_for_user(user_id).await;
if rho.is_none() {
@ -295,12 +298,10 @@ impl GeneralConnection {
*self.rho_connection.write().await = rho.clone();
let client = ClientConnection::from_general(self.clone(), id).await;
if let Some(rho_conn) = rho {
// Make sure user is bound before the client starts forwarding
rho_conn.bind_user_id(user_id).await;
rho_conn.add_client_connection(client.clone()).await;
rho_conn.add_client_connection(client).await;
} else {
log_err!(
user_id,
@ -309,8 +310,6 @@ impl GeneralConnection {
id
);
}
client.start();
}
ConnectionKind::Iota => {
let notify = CommunicationValue::new(CommunicationType::iota_connected)
@ -323,6 +322,10 @@ impl GeneralConnection {
iota.set_rho_connection(rho.clone()).await;
rho_manager::add_rho(rho).await;
iota.clone().start();
let get_iota_msg = CommunicationValue::new(CommunicationType::get_iota_data)
.add_data(DataTypes::iota_id, DataValue::Number(id as i64));
@ -340,10 +343,6 @@ impl GeneralConnection {
iota.set_user_ids(user_ids).await;
}
}
rho_manager::add_rho(rho).await;
iota.start();
}
ConnectionKind::AnonymousClient => {
let client = AnonymousClientConnection::from_general(self.clone(), id).await;

View file

@ -94,7 +94,7 @@ impl IotaConnection {
if let Some(rho_conn) = self.get_rho_connection().await {
let user_ids_i64: Vec<i64> = user_ids.into_iter().map(|u| u as i64).collect();
rho_conn.set_user_ids(user_ids_i64);
rho_conn.set_user_ids(user_ids_i64).await;
}
}