summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Cache.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp
index da3e7099..0426f38a 100644
--- a/src/Cache.cpp
+++ b/src/Cache.cpp
@@ -3624,6 +3624,19 @@ Cache::saveTimelineMessages(lmdb::txn &txn,
             if (redaction->redacts.empty())
                 continue;
 
+            // persist the first redaction in case this is a limited timeline and it is the first
+            // event to not break pagination.
+            if (first && res.limited) {
+                first = false;
+                ++index;
+
+                nhlog::db()->debug("saving redaction '{}'", orderEntry.dump());
+
+                cursor.put(lmdb::to_sv(index), orderEntry.dump(), MDB_APPEND);
+                evToOrderDb.put(txn, event_id, lmdb::to_sv(index));
+                eventsDb.put(txn, event_id, event.dump());
+            }
+
             std::string_view oldEvent;
             bool success = eventsDb.get(txn, redaction->redacts, oldEvent);
             if (!success)
@@ -3671,13 +3684,13 @@ Cache::saveTimelineMessages(lmdb::txn &txn,
             eventsDb.put(txn, redaction->redacts, event.dump());
             eventsDb.put(txn, redaction->event_id, nlohmann::json(*redaction).dump());
         } else {
-            first = false;
-
             // This check protects against duplicates in the timeline. If the event_id
             // is already in the DB, we skip putting it (again) in ordered DBs, and only
             // update the event itself and its relations.
             std::string_view unused_read;
             if (!evToOrderDb.get(txn, event_id, unused_read)) {
+                first = false;
+
                 ++index;
 
                 nhlog::db()->debug("saving '{}'", orderEntry.dump());