mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 08:42:34 +01:00
modules/m_event: Improve pretty_oneline(); add timestamp.
This commit is contained in:
parent
92371040af
commit
70e0fe221f
1 changed files with 32 additions and 23 deletions
|
@ -137,33 +137,35 @@ ircd::m::pretty_oneline(std::ostream &s,
|
||||||
const event &event,
|
const event &event,
|
||||||
const bool &content_keys)
|
const bool &content_keys)
|
||||||
{
|
{
|
||||||
const auto out{[&s]
|
|
||||||
(const string_view &key, auto&& val)
|
|
||||||
{
|
|
||||||
if(defined(json::value(val)))
|
|
||||||
s << val << " ";
|
|
||||||
else
|
|
||||||
s << "* ";
|
|
||||||
}};
|
|
||||||
|
|
||||||
const string_view top_keys[]
|
|
||||||
{
|
|
||||||
"origin",
|
|
||||||
"event_id",
|
|
||||||
"sender",
|
|
||||||
};
|
|
||||||
|
|
||||||
if(defined(json::get<"room_id"_>(event)))
|
if(defined(json::get<"room_id"_>(event)))
|
||||||
s << json::get<"room_id"_>(event) << " ";
|
s << json::get<"room_id"_>(event) << " ";
|
||||||
else
|
else
|
||||||
s << "* ";
|
s << "* ";
|
||||||
|
|
||||||
if(json::get<"depth"_>(event) != json::undefined_number)
|
if(json::get<"depth"_>(event) != json::undefined_number)
|
||||||
s << json::get<"depth"_>(event) << " :";
|
s << json::get<"depth"_>(event) << " ";
|
||||||
else
|
else
|
||||||
s << "* :";
|
s << "* ";
|
||||||
|
|
||||||
json::for_each(event, top_keys, out);
|
if(json::get<"origin_server_ts"_>(event) != json::undefined_number)
|
||||||
|
s << json::get<"origin_server_ts"_>(event) << " ";
|
||||||
|
else
|
||||||
|
s << "* ";
|
||||||
|
|
||||||
|
if(defined(json::get<"origin"_>(event)))
|
||||||
|
s << ':' << json::get<"origin"_>(event) << " ";
|
||||||
|
else
|
||||||
|
s << ":* ";
|
||||||
|
|
||||||
|
if(defined(json::get<"sender"_>(event)))
|
||||||
|
s << json::get<"sender"_>(event) << " ";
|
||||||
|
else
|
||||||
|
s << "* ";
|
||||||
|
|
||||||
|
if(defined(json::get<"event_id"_>(event)))
|
||||||
|
s << json::get<"event_id"_>(event) << " ";
|
||||||
|
else
|
||||||
|
s << "* ";
|
||||||
|
|
||||||
const auto &auth_events{json::get<"auth_events"_>(event)};
|
const auto &auth_events{json::get<"auth_events"_>(event)};
|
||||||
s << "A:" << auth_events.count() << " ";
|
s << "A:" << auth_events.count() << " ";
|
||||||
|
@ -192,7 +194,10 @@ ircd::m::pretty_oneline(std::ostream &s,
|
||||||
}
|
}
|
||||||
s << "] ";
|
s << "] ";
|
||||||
|
|
||||||
out("type", json::get<"type"_>(event));
|
if(defined(json::get<"type"_>(event)))
|
||||||
|
s << json::get<"type"_>(event) << " ";
|
||||||
|
else
|
||||||
|
s << "* ";
|
||||||
|
|
||||||
const auto &state_key
|
const auto &state_key
|
||||||
{
|
{
|
||||||
|
@ -210,11 +215,15 @@ ircd::m::pretty_oneline(std::ostream &s,
|
||||||
{
|
{
|
||||||
json::get<"type"_>(event) == "m.room.member"?
|
json::get<"type"_>(event) == "m.room.member"?
|
||||||
m::membership(event):
|
m::membership(event):
|
||||||
string_view{}
|
"*"_sv
|
||||||
};
|
};
|
||||||
|
|
||||||
out("content.membership", membership);
|
s << membership << " ";
|
||||||
out("redacts", json::get<"redacts"_>(event));
|
|
||||||
|
if(defined(json::get<"redacts"_>(event)))
|
||||||
|
s << json::get<"redacts"_>(event) << " ";
|
||||||
|
else
|
||||||
|
s << "* ";
|
||||||
|
|
||||||
const json::object &contents
|
const json::object &contents
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue