0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd:Ⓜ️:room::events::missing: Add limited iteration overload.

This commit is contained in:
Jason Volk 2019-08-31 00:13:32 -07:00
parent a89b5a5662
commit 52fd0d1b2e
3 changed files with 20 additions and 2 deletions

View file

@ -109,6 +109,7 @@ struct ircd::m::room::events::missing
m::room room;
public:
bool for_each(const int64_t &min_depth, const closure &) const;
bool for_each(const closure &) const;
size_t count() const;

View file

@ -9614,7 +9614,7 @@ console_cmd__room__events__missing(opt &out, const string_view &line)
{
const params param{line, " ",
{
"room_id", "limit", "event_id"
"room_id", "limit", "min_depth", "event_id"
}};
const auto &room_id
@ -9627,6 +9627,11 @@ console_cmd__room__events__missing(opt &out, const string_view &line)
param.at("limit", 16L)
};
const auto &min_depth
{
param.at("min_depth", 0L)
};
const auto &event_id
{
param["event_id"]
@ -9642,7 +9647,7 @@ console_cmd__room__events__missing(opt &out, const string_view &line)
room
};
missing.for_each([&out, &limit]
missing.for_each(min_depth, [&out, &limit]
(const auto &event_id, const auto &ref_depth, const auto &ref_idx)
{
out

View file

@ -194,6 +194,15 @@ bool
IRCD_MODULE_EXPORT
ircd::m::room::events::missing::for_each(const closure &closure)
const
{
return for_each(0L, closure);
}
bool
IRCD_MODULE_EXPORT
ircd::m::room::events::missing::for_each(const int64_t &min_depth,
const closure &closure)
const
{
bool ret{true};
room::events it
@ -203,6 +212,9 @@ const
for(; it && ret; --it)
{
if(it.depth() < min_depth)
break;
const m::event &event{*it};
const m::event::prev prev{event};
ret = m::for_each(prev, [&](const m::event::id &event_id)