0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-29 08:13:46 +02:00

ircd:Ⓜ️:v1:🔑 Add overload for key_id in uri.

This commit is contained in:
Jason Volk 2018-05-11 02:02:46 -07:00
parent 523434b313
commit 42b8d41e58
2 changed files with 25 additions and 1 deletions

View file

@ -30,6 +30,7 @@ struct ircd::m::v1::key::keys
return object;
}
keys(const server_key &, const mutable_buffer &, opts);
keys(const string_view &server_name, const mutable_buffer &, opts);
keys() = default;
};

View file

@ -935,8 +935,21 @@ ircd::m::v1::query::query(const string_view &type,
ircd::m::v1::key::keys::keys(const string_view &server_name,
const mutable_buffer &buf,
opts opts)
:keys
{
server_key{server_name, ""}, buf, std::move(opts)
}
{
}
ircd::m::v1::key::keys::keys(const server_key &server_key,
const mutable_buffer &buf,
opts opts)
:server::request{[&]
{
const auto &server_name{server_key.first};
const auto &key_id{server_key.second};
if(!opts.remote)
opts.remote = net::hostport{server_name};
@ -953,7 +966,17 @@ ircd::m::v1::key::keys::keys(const string_view &server_name,
json::get<"content"_>(opts.request) = json::object{opts.out.content};
if(!defined(json::get<"uri"_>(opts.request)))
json::get<"uri"_>(opts.request) = "/_matrix/key/v2/server/";
{
if(!empty(key_id))
{
thread_local char uribuf[512];
json::get<"uri"_>(opts.request) = fmt::sprintf
{
uribuf, "/_matrix/key/v2/server/%s/", key_id
};
}
else json::get<"uri"_>(opts.request) = "/_matrix/key/v2/server/";
}
json::get<"method"_>(opts.request) = "GET";