From 4eb76fd154f2fc713087855a5570893cd28da795 Mon Sep 17 00:00:00 2001 From: Paul <paulmakles@gmail.com> Date: Fri, 19 Feb 2021 15:24:19 +0000 Subject: [PATCH] Fix mutex issues. --- src/notifications/websocket.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/notifications/websocket.rs b/src/notifications/websocket.rs index eaceedf..121c58e 100644 --- a/src/notifications/websocket.rs +++ b/src/notifications/websocket.rs @@ -163,10 +163,15 @@ async fn accept(stream: TcpStream) { // ! Could just run permission check here. ServerboundNotification::BeginTyping { channel } => { if mutex.lock().unwrap().is_some() { + let user = { + let mutex = mutex.lock().unwrap(); + let session = mutex.as_ref().unwrap(); + session.user_id.clone() + }; + ClientboundNotification::ChannelStartTyping { id: channel.clone(), - // lol - user: mutex.lock().as_ref().unwrap().as_ref().unwrap().user_id.clone() + user } .publish(channel) .await @@ -181,9 +186,15 @@ async fn accept(stream: TcpStream) { } ServerboundNotification::EndTyping { channel } => { if mutex.lock().unwrap().is_some() { + let user = { + let mutex = mutex.lock().unwrap(); + let session = mutex.as_ref().unwrap(); + session.user_id.clone() + }; + ClientboundNotification::ChannelStopTyping { id: channel.clone(), - user: mutex.lock().as_ref().unwrap().as_ref().unwrap().user_id.clone() + user } .publish(channel) .await -- GitLab