Reworked subscriptions
This commit is contained in:
@ -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(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user