summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/mattermost.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/mattermost.rs b/src/mattermost.rs
index 7742e3e..a062887 100644
--- a/src/mattermost.rs
+++ b/src/mattermost.rs
@@ -2,7 +2,7 @@ use anyhow::anyhow;
 use async_tungstenite::{tokio::connect_async, tungstenite::Message};
 use futures_util::{SinkExt, StreamExt};
 use serde_json::json;
-use tracing::debug;
+use tracing::{debug, warn};
 pub struct AuthData {
     pub(crate) login: String,
     pub(crate) password: String,
@@ -56,7 +56,22 @@ impl Client {
             ))
             .await?;
         while let Some(message) = ws_stream.next().await {
-            debug!("{:?}", message);
+            match message {
+                Ok(message) => match message {
+                    Message::Text(text) => {
+                        let json: Result<serde_json::Value, _> = serde_json::from_str(&text);
+                        match json {
+                            Ok(json) => debug!("Got json {json}"),
+                            Err(err) => warn!("Error while deserializing {err}"),
+                        }
+                    }
+                    Message::Close(_) => break,
+                    _ => {
+                        debug!("Message {message:?}");
+                    }
+                },
+                Err(err) => warn!("Error {err} while reading message"),
+            }
         }
         Ok(())
     }