mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 00:34:18 +01:00
modules/m_keys: Improve cache::get query.
This commit is contained in:
parent
4947ef10f5
commit
e0ff0dfd3c
1 changed files with 11 additions and 9 deletions
|
@ -425,18 +425,20 @@ ircd::m::keys::cache::get(const string_view &server_name,
|
|||
server_name
|
||||
};
|
||||
|
||||
const auto reclosure{[&closure]
|
||||
(const m::event &event)
|
||||
{
|
||||
closure(json::get<"content"_>(event));
|
||||
}};
|
||||
|
||||
// Without a key_id we search for the most recent key; note this is not
|
||||
// the same as making a state_key="" query, as that would be an actual
|
||||
// ircd.key entry without an id (which shouldn't exist).
|
||||
return !key_id?
|
||||
node_room.get(std::nothrow, "ircd.key", reclosure):
|
||||
node_room.get(std::nothrow, "ircd.key", key_id, reclosure);
|
||||
const event::idx &event_idx
|
||||
{
|
||||
key_id?
|
||||
node_room.get(std::nothrow, "ircd.key", key_id):
|
||||
node_room.get(std::nothrow, "ircd.key")
|
||||
};
|
||||
|
||||
if(!event_idx)
|
||||
return false;
|
||||
|
||||
return m::get(std::nothrow, event_idx, "content", closure);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Loading…
Reference in a new issue