0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-01 21:28:53 +02:00

modules/console: Add compose finalizer convenience.

This commit is contained in:
Jason Volk 2018-05-27 06:11:45 -07:00
parent 377276432b
commit 8dc3e7c758

View file

@ -2522,6 +2522,44 @@ console_cmd__compose(opt &out, const string_view &line)
return true;
}
bool
console_cmd__compose__final(opt &out, const string_view &line)
{
const params param{line, " ",
{
"[id]",
}};
const int &id
{
param.at<int>(0, -1)
};
m::event event
{
compose.at(id)
};
m::event::id::buf event_id_buf;
json::get<"event_id"_>(event) = make_id(event, event_id_buf);
thread_local char hashes_buf[512];
json::get<"hashes"_>(event) = m::hashes(hashes_buf, event);
thread_local char sigs_buf[512];
event = signatures(sigs_buf, event);
compose.at(id) = json::strung
{
event
};
event = m::event(compose.at(id));
out << pretty(event) << std::endl;
out << compose.at(id) << std::endl;
return true;
}
bool
console_cmd__compose__clear(opt &out, const string_view &line)
{