summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-03-20 21:26:49 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2023-03-20 21:26:49 +0100
commit7d5c0b78229dcc83b4a102cf5a269e17b941554d (patch)
tree9766bbb88d14830dfa77ead2fef5a17280eaaf59 /src
parentOptimize event accessors a bit (diff)
downloadnheko-7d5c0b78229dcc83b4a102cf5a269e17b941554d.tar.xz
All around me are empty spaces
Diffstat (limited to 'src')
-rw-r--r--src/Cache.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp
index 3e72b7ad..aecf5f7c 100644
--- a/src/Cache.cpp
+++ b/src/Cache.cpp
@@ -1956,14 +1956,24 @@ Cache::saveState(const mtx::responses::Sync &res)
             bool room_has_space_update = false;
             for (const auto &e : room.second.state.events) {
                 if (auto se = std::get_if<StateEvent<state::space::Parent>>(&e)) {
-                    spaces_with_updates.insert(se->state_key);
-                    room_has_space_update = true;
+                    if (se->state_key.empty()) {
+                        nhlog::db()->warn("Skipping space parent with empty state key in room {}",
+                                          room.first);
+                    } else {
+                        spaces_with_updates.insert(se->state_key);
+                        room_has_space_update = true;
+                    }
                 }
             }
             for (const auto &e : room.second.timeline.events) {
                 if (auto se = std::get_if<StateEvent<state::space::Parent>>(&e)) {
-                    spaces_with_updates.insert(se->state_key);
-                    room_has_space_update = true;
+                    if (se->state_key.empty()) {
+                        nhlog::db()->warn("Skipping space child with empty state key in room {}",
+                                          room.first);
+                    } else {
+                        spaces_with_updates.insert(se->state_key);
+                        room_has_space_update = true;
+                    }
                 }
             }
 
@@ -2013,8 +2023,8 @@ Cache::saveState(const mtx::responses::Sync &res)
 
         if (auto newRoomInfoDump = nlohmann::json(updatedInfo).dump();
             newRoomInfoDump != originalRoomInfoDump) {
-            nhlog::db()->critical(
-              "Writing out new room info:\n{}\n{}", originalRoomInfoDump, newRoomInfoDump);
+            // nhlog::db()->critical(
+            //   "Writing out new room info:\n{}\n{}", originalRoomInfoDump, newRoomInfoDump);
             roomsDb_.put(txn, room.first, newRoomInfoDump);
         }