From 2407d4da3a6e67d63407421883f8d37ea4c52324 Mon Sep 17 00:00:00 2001
From: Paul <paulmakles@gmail.com>
Date: Tue, 27 Jul 2021 14:22:41 +0100
Subject: [PATCH] Deprecate UserPresence event.

---
 src/notifications/events.rs    |  4 ----
 src/notifications/websocket.rs | 14 ++++++++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/notifications/events.rs b/src/notifications/events.rs
index aa28cd7..a1f5b79 100644
--- a/src/notifications/events.rs
+++ b/src/notifications/events.rs
@@ -157,10 +157,6 @@ pub enum ClientboundNotification {
         user: User,
         status: RelationshipStatus,
     },
-    UserPresence {
-        id: String,
-        online: bool,
-    },
     UserSettingsUpdate {
         id: String,
         update: JsonValue,
diff --git a/src/notifications/websocket.rs b/src/notifications/websocket.rs
index 5046f77..29bf3b3 100644
--- a/src/notifications/websocket.rs
+++ b/src/notifications/websocket.rs
@@ -129,9 +129,12 @@ async fn accept(stream: TcpStream) {
                                         send(payload);
 
                                         if !was_online {
-                                            ClientboundNotification::UserPresence {
+                                            ClientboundNotification::UserUpdate {
                                                 id: id.clone(),
-                                                online: true,
+                                                data: json!({
+                                                    "online": true
+                                                }),
+                                                clear: None
                                             }
                                             .publish(id);
                                         }
@@ -228,9 +231,12 @@ async fn accept(stream: TcpStream) {
     }
 
     if let Some(id) = offline {
-        ClientboundNotification::UserPresence {
+        ClientboundNotification::UserUpdate {
             id: id.clone(),
-            online: false,
+            data: json!({
+                "online": false
+            }),
+            clear: None
         }
         .publish(id);
     }
-- 
GitLab