1
0
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:
2021-02-06 11:58:22 +01:00
parent 3e4d2872ea
commit dab76a3677
4 changed files with 74 additions and 9 deletions

View File

@@ -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,