From 8146b730e279bc231aa4812f3755eac1d04d4dfd Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 16 May 2018 13:46:50 -0700 Subject: [PATCH] modules/key/keys: Fix cache query for empty key_id: find latest key. --- modules/key/keys.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/key/keys.cc b/modules/key/keys.cc index db244c2e8..7b880060b 100644 --- a/modules/key/keys.cc +++ b/modules/key/keys.cc @@ -238,6 +238,16 @@ cache_get(const string_view &server_name, node_id }; + // 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). + if(!key_id) + return node_room.get(std::nothrow, "ircd.key", [&closure] + (const m::event &event) + { + closure(json::get<"content"_>(event)); + }); + return node_room.get(std::nothrow, "ircd.key", key_id, [&closure] (const m::event &event) {