mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 02:02:38 +01:00
ircd:Ⓜ️:room::events::missing: Implement iteration; console cmd.
This commit is contained in:
parent
91862e381f
commit
56d80751ec
2 changed files with 76 additions and 1 deletions
|
@ -9569,6 +9569,56 @@ console_cmd__room__events(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__room__events__missing(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"room_id"
|
||||
}};
|
||||
|
||||
const auto &room_id
|
||||
{
|
||||
m::room_id(param.at("room_id"))
|
||||
};
|
||||
|
||||
const auto &event_id
|
||||
{
|
||||
param[2]
|
||||
};
|
||||
|
||||
const m::room room
|
||||
{
|
||||
room_id, event_id
|
||||
};
|
||||
|
||||
const m::room::events::missing missing
|
||||
{
|
||||
room
|
||||
};
|
||||
|
||||
missing.for_each([&out]
|
||||
(const auto &event_id, const auto &ref_depth, const auto &ref_idx)
|
||||
{
|
||||
out
|
||||
<< std::right
|
||||
<< std::setw(10)
|
||||
<< ref_idx
|
||||
<< " "
|
||||
<< std::right
|
||||
<< std::setw(8)
|
||||
<< ref_depth
|
||||
<< " "
|
||||
<< std::left
|
||||
<< std::setw(52)
|
||||
<< event_id
|
||||
<< std::endl;
|
||||
return true;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__room__messages(opt &out, const string_view &line)
|
||||
{
|
||||
|
|
|
@ -179,7 +179,32 @@ IRCD_MODULE_EXPORT
|
|||
ircd::m::room::events::missing::for_each(const closure &closure)
|
||||
const
|
||||
{
|
||||
return true;
|
||||
const std::function<bool (const string_view &)> in_room
|
||||
{
|
||||
[this](const string_view &room_id)
|
||||
{
|
||||
return room_id == this->room.room_id;
|
||||
}
|
||||
};
|
||||
|
||||
return event::horizon::for_every([&in_room, &closure]
|
||||
(const event::id &event_id, const event::idx &event_idx)
|
||||
{
|
||||
if(!m::query(event_idx, "room_id", false, in_room))
|
||||
return true;
|
||||
|
||||
if(m::exists(event_id))
|
||||
return true;
|
||||
|
||||
uint64_t depth;
|
||||
if(!m::get(event_idx, "depth", depth))
|
||||
return true;
|
||||
|
||||
if(!closure(event_id, depth, event_idx))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue