Reworked subscriptions

This commit is contained in:
2021-06-05 15:39:45 +02:00
parent 01e9b9c6ae
commit 31092c4a24

View File

@ -50,25 +50,27 @@ pub async fn push(room_id: &str, event: Event) -> Result<(), Error> {
} }
}; };
unsafe { let mut rooms = unsafe {
let mut rooms = ROOMS.as_ref().unwrap().lock().await; let mut rooms = ROOMS.as_ref().unwrap().lock().await;
if let Some(rooms) = rooms.get_mut(room_id) { if let Some(rooms) = rooms.get_mut(room_id) {
for tx in rooms { rooms.clone()
let _res = tx.send(event.clone()).await; } else {
} Vec::new()
}
} }
};
for account in accounts { for account in accounts {
unsafe { unsafe {
let mut accounts = ACCOUNTS.as_ref().unwrap().lock().await; let mut accounts = ACCOUNTS.as_ref().unwrap().lock().await;
if let Some(acc) = accounts.get_mut(account.as_str()) { if let Some(acc) = accounts.get_mut(account.as_str()) {
for tx in acc { rooms.append(acc);
let _res = tx.send(event.clone()).await;
}
} }
} }
} }
for tx in rooms {
let _res = tx.send(event.clone()).await;
}
Ok(()) Ok(())
} }