From 9f5b647fb38d1f362c557d707274597189942c48 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 27 Feb 2022 05:02:54 +0100 Subject: Fix editing pending messages --- src/Cache.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/Cache.cpp') diff --git a/src/Cache.cpp b/src/Cache.cpp index 6bad336a..be3dfe69 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -2931,6 +2931,28 @@ Cache::savePendingMessage(const std::string &room_id, txn.commit(); } +std::vector +Cache::pendingEvents(const std::string &room_id) +{ + auto txn = ro_txn(env_); + auto pending = getPendingMessagesDb(txn, room_id); + + std::vector related_ids; + + try { + { + auto pendingCursor = lmdb::cursor::open(txn, pending); + std::string_view tsIgnored, pendingTxn; + while (pendingCursor.get(tsIgnored, pendingTxn, MDB_NEXT)) { + related_ids.emplace_back(pendingTxn.data(), pendingTxn.size()); + } + } + } catch (const lmdb::error &e) { + nhlog::db()->error("pending events error: {}", e.what()); + } + + return related_ids; +} std::optional Cache::firstPendingMessage(const std::string &room_id) -- cgit 1.5.1