1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 00:45:18 +00:00

Propagate unread conversations number update

This commit is contained in:
2021-02-06 16:26:53 +01:00
parent dab76a3677
commit 7cf5977da2
3 changed files with 30 additions and 2 deletions

View File

@ -344,6 +344,20 @@ pub fn delete_message(r: &mut HttpRequestHandler) -> RequestResult {
/// Events handler
pub fn handle_event(e: &events_helper::Event) -> Res {
match e {
Event::UpdatedNumberUnreadConversations(users) => {
for user in users.iter() {
if user_ws_controller::is_user_connected(user) {
user_ws_controller::send_message_to_user(
&UserWsMessage::no_id_message(
"number_unread_conversations",
conversations_helper::count_unread_for_user(user)?,
)?,
user,
)?;
}
}
}
Event::NewConversationMessage(msg) => {
user_ws_controller::send_message_to_specific_connections(
|f| f.conversations.contains(&msg.conv_id),