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;
if let Some(rooms) = rooms.get_mut(room_id) {
for tx in rooms {
let _res = tx.send(event.clone()).await;
}
}
rooms.clone()
} else {
Vec::new()
}
};
for account in accounts {
unsafe {
let mut accounts = ACCOUNTS.as_ref().unwrap().lock().await;
if let Some(acc) = accounts.get_mut(account.as_str()) {
for tx in acc {
let _res = tx.send(event.clone()).await;
}
rooms.append(acc);
}
}
}
for tx in rooms {
let _res = tx.send(event.clone()).await;
}
Ok(())
}