Render edits
This commit is contained in:
parent
2e77a1554f
commit
d6504812c7
4 changed files with 86 additions and 4 deletions
|
|
@ -108,6 +108,11 @@ Cache::isHiddenEvent(lmdb::txn &txn,
|
|||
const std::string &room_id)
|
||||
{
|
||||
using namespace mtx::events;
|
||||
|
||||
// Always hide edits
|
||||
if (mtx::accessors::relations(e).replaces())
|
||||
return true;
|
||||
|
||||
if (auto encryptedEvent = std::get_if<EncryptedEvent<msg::Encrypted>>(&e)) {
|
||||
MegolmSessionIndex index;
|
||||
index.room_id = room_id;
|
||||
|
|
@ -1891,6 +1896,31 @@ Cache::getTimelineIndex(const std::string &room_id, std::string_view event_id)
|
|||
return *val.data<uint64_t>();
|
||||
}
|
||||
|
||||
std::optional<uint64_t>
|
||||
Cache::getArrivalIndex(const std::string &room_id, std::string_view event_id)
|
||||
{
|
||||
auto txn = lmdb::txn::begin(env_, nullptr, MDB_RDONLY);
|
||||
|
||||
lmdb::dbi orderDb{0};
|
||||
try {
|
||||
orderDb = getEventToOrderDb(txn, room_id);
|
||||
} catch (lmdb::runtime_error &e) {
|
||||
nhlog::db()->error("Can't open db for room '{}', probably doesn't exist yet. ({})",
|
||||
room_id,
|
||||
e.what());
|
||||
return {};
|
||||
}
|
||||
|
||||
lmdb::val indexVal{event_id.data(), event_id.size()}, val;
|
||||
|
||||
bool success = lmdb::dbi_get(txn, orderDb, indexVal, val);
|
||||
if (!success) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return *val.data<uint64_t>();
|
||||
}
|
||||
|
||||
std::optional<std::string>
|
||||
Cache::getTimelineEventId(const std::string &room_id, uint64_t index)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue