From 2050a0609f2ee5c534b610a52931c218e4d1591a Mon Sep 17 00:00:00 2001
From: Paul <paulmakles@gmail.com>
Date: Sat, 3 Apr 2021 21:37:24 +0100
Subject: [PATCH] Fix update_one failing on sys message.

---
 src/database/entities/message.rs | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/database/entities/message.rs b/src/database/entities/message.rs
index 1d48c2d..b506ccc 100644
--- a/src/database/entities/message.rs
+++ b/src/database/entities/message.rs
@@ -119,19 +119,21 @@ impl Message {
                     })?;
             }
             Channel::Group { id, .. } => {
-                channels
-                    .update_one(
-                        doc! { "_id": id },
-                        doc! {
-                            "$set": set
-                        },
-                        None,
-                    )
-                    .await
-                    .map_err(|_| Error::DatabaseError {
-                        operation: "update_one",
-                        with: "channel",
-                    })?;
+                if let Content::Text(_) = &self.content {
+                    channels
+                        .update_one(
+                            doc! { "_id": id },
+                            doc! {
+                                "$set": set
+                            },
+                            None,
+                        )
+                        .await
+                        .map_err(|_| Error::DatabaseError {
+                            operation: "update_one",
+                            with: "channel",
+                        })?;
+                }
             }
             _ => {}
         }
@@ -140,7 +142,7 @@ impl Message {
         ClientboundNotification::Message(self)
             .publish(channel.id().to_string())
             .await
-            .ok();
+            .unwrap();
 
         /*
            Web Push Test Code
-- 
GitLab