From 7a907760560a288262920c7257f5ec69ab70a683 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 19 Aug 2022 11:13:57 -0700 Subject: [PATCH] ircd::m: Additional pretty_msgline() opts for time ago / body delim. --- include/ircd/m/pretty.h | 2 ++ matrix/pretty.cc | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/ircd/m/pretty.h b/include/ircd/m/pretty.h index 14c930911..cab4bef80 100644 --- a/include/ircd/m/pretty.h +++ b/include/ircd/m/pretty.h @@ -46,9 +46,11 @@ struct ircd::m::pretty_opts bool show_event_idx {true}; bool show_depth {true}; bool show_origin_server_ts {true}; + bool show_origin_server_ts_ago {false}; bool show_event_id {true}; bool show_sender {true}; bool show_state_key {true}; bool show_content {true}; bool show_msgtype {true}; + char body_delim {':'}; }; diff --git a/matrix/pretty.cc b/matrix/pretty.cc index e69ab5cbf..5e0c7c377 100644 --- a/matrix/pretty.cc +++ b/matrix/pretty.cc @@ -638,6 +638,14 @@ ircd::m::pretty_msgline(std::ostream &s, s << smalldate(sdbuf, json::get<"origin_server_ts"_>(event) / 1000L) << ' '; } + if(opts.show_origin_server_ts_ago) + { + char buf[48]; + const system_point p(milliseconds(json::get<"origin_server_ts"_>(event))); + if(json::get<"origin_server_ts"_>(event) != json::undefined_number) + s << ago(buf, p, 0x3) << ' '; + } + if(opts.show_event_id) s << event.event_id << ' '; @@ -685,8 +693,9 @@ ircd::m::pretty_msgline(std::ostream &s, if(opts.show_msgtype) s << type << ' '; - else if(type != "m.text") - break; + + if(opts.body_delim) + s << opts.body_delim; s << msg.body(); break;