summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-05-06 21:07:21 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2023-05-06 21:16:54 +0200
commit0a55c8ee175c9538849b81f7a47779c101d355ca (patch)
tree29bab89c215ccd7c012ae35d632f7c1f223c0bc3 /src
parentSort rooms in completer by 'activity' and make tombstoned rooms italic (diff)
downloadnheko-0a55c8ee175c9538849b81f7a47779c101d355ca.tar.xz
Delete unused msg db function
Diffstat (limited to 'src')
-rw-r--r--src/Cache.cpp57
-rw-r--r--src/Cache_p.h12
2 files changed, 1 insertions, 68 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp
index 1681f02c..44f2ecb0 100644
--- a/src/Cache.cpp
+++ b/src/Cache.cpp
@@ -45,8 +45,7 @@ static const std::string_view OLM_ACCOUNT_KEY("olm_account");
 static const std::string_view CACHE_FORMAT_VERSION_KEY("cache_format_version");
 static const std::string_view CURRENT_ONLINE_BACKUP_VERSION("current_online_backup_version");
 
-static constexpr auto MAX_DBS    = 32384UL;
-static constexpr auto BATCH_SIZE = 100;
+static constexpr auto MAX_DBS = 32384UL;
 
 #if Q_PROCESSOR_WORDSIZE >= 5 // 40-bit or more, up to 2^(8*WORDSIZE) words addressable.
 static constexpr auto DB_SIZE                 = 32ULL * 1024ULL * 1024ULL * 1024ULL; // 32 GB
@@ -2362,60 +2361,6 @@ Cache::previousBatchToken(const std::string &room_id)
     }
 }
 
-Cache::Messages
-Cache::getTimelineMessages(lmdb::txn &txn, const std::string &room_id, uint64_t index, bool forward)
-{
-    // TODO(nico): Limit the messages returned by this maybe?
-    auto orderDb  = getOrderToMessageDb(txn, room_id);
-    auto eventsDb = getEventsDb(txn, room_id);
-
-    Messages messages{};
-
-    std::string_view indexVal, event_id;
-
-    auto cursor = lmdb::cursor::open(txn, orderDb);
-    if (index == std::numeric_limits<uint64_t>::max()) {
-        if (!cursor.get(indexVal, event_id, forward ? MDB_FIRST : MDB_LAST)) {
-            messages.end_of_cache = true;
-            return messages;
-        }
-    } else {
-        if (!cursor.get(indexVal, event_id, MDB_SET)) {
-            messages.end_of_cache = true;
-            return messages;
-        }
-    }
-
-    int counter = 0;
-
-    bool ret;
-    while ((ret = cursor.get(indexVal,
-                             event_id,
-                             counter == 0 ? (forward ? MDB_FIRST : MDB_LAST)
-                                          : (forward ? MDB_NEXT : MDB_PREV))) &&
-           counter++ < BATCH_SIZE) {
-        std::string_view event;
-        bool success = eventsDb.get(txn, event_id, event);
-        if (!success)
-            continue;
-
-        try {
-            messages.timeline.events.push_back(
-              nlohmann::json::parse(event).get<mtx::events::collections::TimelineEvents>());
-        } catch (std::exception &e) {
-            nhlog::db()->error("Failed to parse message from cache {}", e.what());
-            continue;
-        }
-    }
-    cursor.close();
-
-    // std::reverse(timeline.events.begin(), timeline.events.end());
-    messages.next_index   = lmdb::from_sv<uint64_t>(indexVal);
-    messages.end_of_cache = !ret;
-
-    return messages;
-}
-
 std::optional<mtx::events::collections::TimelineEvents>
 Cache::getEvent(const std::string &room_id, std::string_view event_id)
 {
diff --git a/src/Cache_p.h b/src/Cache_p.h
index 7526d9b8..f8716e81 100644
--- a/src/Cache_p.h
+++ b/src/Cache_p.h
@@ -183,18 +183,6 @@ public:
     //! Check if we have sent a desktop notification for the given event id.
     bool isNotificationSent(const std::string &event_id);
 
-    //! retrieve events in timeline and related functions
-    struct Messages
-    {
-        mtx::responses::Timeline timeline;
-        uint64_t next_index;
-        bool end_of_cache = false;
-    };
-    Messages getTimelineMessages(lmdb::txn &txn,
-                                 const std::string &room_id,
-                                 uint64_t index = std::numeric_limits<uint64_t>::max(),
-                                 bool forward   = false);
-
     std::optional<mtx::events::collections::TimelineEvents>
     getEvent(const std::string &room_id, std::string_view event_id);
     void storeEvent(const std::string &room_id,