mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd:Ⓜ️:keys::cache: Add has() to interface.
This commit is contained in:
parent
3d4ea0a313
commit
766dfe027d
2 changed files with 20 additions and 0 deletions
|
@ -73,6 +73,7 @@ struct ircd::m::keys
|
|||
struct ircd::m::keys::cache
|
||||
{
|
||||
static bool for_each(const string_view &server, const closure_bool &);
|
||||
static bool has(const string_view &server, const string_view &key_id);
|
||||
static bool get(const string_view &server, const string_view &key_id, const closure &);
|
||||
static size_t set(const json::object &keys);
|
||||
};
|
||||
|
|
|
@ -538,6 +538,25 @@ ircd::m::keys::cache::get(const string_view &server_name,
|
|||
return m::get(std::nothrow, event_idx, "content", closure);
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::keys::cache::has(const string_view &server_name,
|
||||
const string_view &key_id)
|
||||
{
|
||||
const m::node::room node_room
|
||||
{
|
||||
server_name
|
||||
};
|
||||
|
||||
// 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.has("ircd.key", key_id):
|
||||
node_room.has("ircd.key");
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::keys::cache::for_each(const string_view &server_name,
|
||||
|
|
Loading…
Reference in a new issue