0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 08:42:34 +01:00

modules/console: Add fed user keys claim cmd.

This commit is contained in:
Jason Volk 2019-02-22 14:48:17 -08:00
parent 08c38b2251
commit 8dbd0ae829

View file

@ -10954,6 +10954,67 @@ console_cmd__fed__user__keys__query(opt &out, const string_view &line)
return true;
}
bool
console_cmd__fed__user__keys__claim(opt &out, const string_view &line)
{
const params param{line, " ",
{
"user_id", "device_id", "algorithm", "remote"
}};
const m::user::id &user_id
{
param.at("user_id")
};
const string_view &device_id
{
param.at("device_id")
};
const string_view &algorithm
{
param.at("algorithm")
};
const net::hostport remote
{
param.at("remote", user_id.host())
};
m::v1::user::opts opts;
opts.remote = remote;
const unique_buffer<mutable_buffer> buf
{
32_KiB
};
m::v1::user::keys::claim request
{
user_id, device_id, algorithm, buf, std::move(opts)
};
request.wait(out.timeout);
const auto code
{
request.get()
};
const json::object &response
{
request
};
const json::object &one_time_keys
{
response["one_time_keys"]
};
out << one_time_keys << std::endl;
return true;
}
bool
console_cmd__fed__key(opt &out, const string_view &line)
{