Fix editing pending messages

This commit is contained in:
Nicolas Werner 2022-02-27 05:02:54 +01:00
parent 4946548997
commit 9f5b647fb3
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
3 changed files with 31 additions and 10 deletions

View file

@ -2931,6 +2931,28 @@ Cache::savePendingMessage(const std::string &room_id,
txn.commit();
}
std::vector<std::string>
Cache::pendingEvents(const std::string &room_id)
{
auto txn = ro_txn(env_);
auto pending = getPendingMessagesDb(txn, room_id);
std::vector<std::string> 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<mtx::events::collections::TimelineEvent>
Cache::firstPendingMessage(const std::string &room_id)