mirror of
https://github.com/matrix-construct/construct
synced 2024-09-25 09:58:54 +02:00
ircd:Ⓜ️:room::type: Add prefix matching option.
This commit is contained in:
parent
d1f9b11b4c
commit
36b1fa6bde
2 changed files with 11 additions and 4 deletions
|
@ -25,6 +25,7 @@ struct ircd::m::room::type
|
|||
m::room room;
|
||||
string_view _type;
|
||||
std::pair<uint64_t, int64_t> range; // highest (inclusive) to lowest (exclusive)
|
||||
bool prefixing; // true = startswith(type)
|
||||
|
||||
public:
|
||||
bool for_each(const closure &) const;
|
||||
|
@ -33,7 +34,8 @@ struct ircd::m::room::type
|
|||
|
||||
type(const m::room &,
|
||||
const string_view &type = {},
|
||||
const decltype(range) & = { -1UL, -1L });
|
||||
const decltype(range) & = { -1UL, -1L },
|
||||
const bool &prefixing = false);
|
||||
|
||||
static bool prefetch(const room::id &, const string_view &type, const int64_t &depth);
|
||||
static bool prefetch(const room::id &, const string_view &type);
|
||||
|
@ -42,8 +44,10 @@ struct ircd::m::room::type
|
|||
inline
|
||||
ircd::m::room::type::type(const m::room &room,
|
||||
const string_view &type,
|
||||
const decltype(range) &range)
|
||||
const decltype(range) &range,
|
||||
const bool &prefixing)
|
||||
:room{room}
|
||||
,_type{type}
|
||||
,range{range}
|
||||
,prefixing{prefixing}
|
||||
{}
|
||||
|
|
|
@ -77,10 +77,13 @@ const
|
|||
dbs::room_type_key(it->first)
|
||||
};
|
||||
|
||||
if(this->_type && this->_type != _type)
|
||||
if(int64_t(depth) <= range.second)
|
||||
break;
|
||||
|
||||
if(int64_t(depth) <= range.second)
|
||||
if(this->_type && !prefixing && this->_type != _type)
|
||||
break;
|
||||
|
||||
if(this->_type && prefixing && !startswith(_type, this->_type))
|
||||
break;
|
||||
|
||||
if(!closure(_type, depth, event_idx))
|
||||
|
|
Loading…
Reference in a new issue