mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 13:08:48 +03:00
parent
c600827f78
commit
d81e3f94e7
1 changed files with 23 additions and 16 deletions
|
@ -1914,7 +1914,7 @@ Cache::getTimelineIndex(const std::string &room_id, std::string_view event_id)
|
||||||
std::optional<uint64_t>
|
std::optional<uint64_t>
|
||||||
Cache::getEventIndex(const std::string &room_id, std::string_view event_id)
|
Cache::getEventIndex(const std::string &room_id, std::string_view event_id)
|
||||||
{
|
{
|
||||||
if (event_id.empty())
|
if (room_id.empty() || event_id.empty())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
auto txn = ro_txn(env_);
|
auto txn = ro_txn(env_);
|
||||||
|
@ -1942,7 +1942,7 @@ Cache::getEventIndex(const std::string &room_id, std::string_view event_id)
|
||||||
std::optional<std::pair<uint64_t, std::string>>
|
std::optional<std::pair<uint64_t, std::string>>
|
||||||
Cache::lastInvisibleEventAfter(const std::string &room_id, std::string_view event_id)
|
Cache::lastInvisibleEventAfter(const std::string &room_id, std::string_view event_id)
|
||||||
{
|
{
|
||||||
if (event_id.empty())
|
if (room_id.empty() || event_id.empty())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
auto txn = ro_txn(env_);
|
auto txn = ro_txn(env_);
|
||||||
|
@ -1967,6 +1967,8 @@ Cache::lastInvisibleEventAfter(const std::string &room_id, std::string_view even
|
||||||
if (!success) {
|
if (!success) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
uint64_t prevIdx = lmdb::from_sv<uint64_t>(indexVal);
|
uint64_t prevIdx = lmdb::from_sv<uint64_t>(indexVal);
|
||||||
std::string prevId{event_id};
|
std::string prevId{event_id};
|
||||||
|
|
||||||
|
@ -1984,6 +1986,11 @@ Cache::lastInvisibleEventAfter(const std::string &room_id, std::string_view even
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::pair{prevIdx, std::string(prevId)};
|
return std::pair{prevIdx, std::string(prevId)};
|
||||||
|
} catch (lmdb::runtime_error &e) {
|
||||||
|
nhlog::db()->error(
|
||||||
|
"Failed to get last invisible event after {}", event_id, e.what());
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<uint64_t>
|
std::optional<uint64_t>
|
||||||
|
|
Loading…
Reference in a new issue