mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-09-25 22:29:45 +00:00
Notify about notifications number update
This commit is contained in:
@@ -486,6 +486,23 @@ pub fn send_message_to_users(msg: &UserWsMessage, users: &Vec<UserID>) -> Res {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Send a message to a specific user
|
||||
pub fn send_message_to_user(msg: &UserWsMessage, user: &UserID) -> Res {
|
||||
let connections = get_ws_connections_list()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|f| user == &f.user_id)
|
||||
.map(|f| f.session.clone())
|
||||
.collect::<Vec<Addr<WsSession>>>();
|
||||
|
||||
for con in connections {
|
||||
send_message(con, msg)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Send a message to specific users
|
||||
pub fn send_message_to_specific_connections<F, M, A>(filter: F, msg_generator: M, after_send: Option<A>) -> Res
|
||||
where F: Fn(&WsConnection) -> bool,
|
||||
|
Reference in New Issue
Block a user