diff --git a/include/ircd/m/relates.h b/include/ircd/m/relates.h index 9cdecc4a7..0b463fc6a 100644 --- a/include/ircd/m/relates.h +++ b/include/ircd/m/relates.h @@ -44,9 +44,11 @@ struct ircd::m::relates const event::idx &, const json::object &, const m::relates_to & >; + static conf::item latest_column; + event::refs refs; bool match_sender {false}; - bool prefetch_depth {false}; + bool prefetch_latest {false}; bool prefetch_sender {false}; private: diff --git a/matrix/relates.cc b/matrix/relates.cc index 38552a2bc..c8bddce54 100644 --- a/matrix/relates.cc +++ b/matrix/relates.cc @@ -8,6 +8,13 @@ // copyright notice and this permission notice is present in all copies. The // full license for this software is available in the LICENSE file. +decltype(ircd::m::relates::latest_column) +ircd::m::relates::latest_column +{ + { "name", "ircd.m.relates.latest_column" }, + { "default", "origin_server_ts" }, +}; + bool ircd::m::relates::prefetch(const string_view &type) const @@ -21,8 +28,8 @@ const refs.for_each(dbs::ref::M_RELATES, [this, &ret] (const auto &event_idx, const auto &) { - if(this->prefetch_depth) - ret |= m::prefetch(event_idx, "depth"); + if(this->prefetch_latest) + ret |= m::prefetch(event_idx, string_view{latest_column}); if(this->prefetch_sender || this->match_sender) ret |= m::prefetch(event_idx, "sender"); @@ -87,6 +94,11 @@ ircd::m::relates::latest(const string_view &type, uint *const at) const { + const string_view &column + { + latest_column + }; + if(at) *at = -1; @@ -97,10 +109,10 @@ const (const event::idx &event_idx, const json::object &, const m::relates_to &) noexcept { - int64_t depth{0}; - if((depth = m::get(std::nothrow, event_idx, "depth", depth)) > best) + int64_t val{0}; + if((val = m::get(std::nothrow, event_idx, column, val)) > best) { - best = depth; + best = val; ret = event_idx; if(at)