mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 00:32:35 +01:00
ircd:Ⓜ️:user::rooms: Optimize user rooms iteration.
This commit is contained in:
parent
3a673dadf4
commit
01019640cd
1 changed files with 18 additions and 26 deletions
44
ircd/m.cc
44
ircd/m.cc
|
@ -2692,40 +2692,32 @@ ircd::m::user::rooms::for_each(const string_view &membership,
|
|||
const closure_bool &closure)
|
||||
const
|
||||
{
|
||||
// Setup the list of event fields to fetch for the closure
|
||||
static const event::keys::include keys
|
||||
{
|
||||
"state_key", "content",
|
||||
};
|
||||
|
||||
const m::event::fetch::opts fopts
|
||||
{
|
||||
keys, user_room.fopts? user_room.fopts->gopts : db::gopts{}
|
||||
};
|
||||
|
||||
const m::room::state state
|
||||
{
|
||||
user_room, &fopts
|
||||
user_room
|
||||
};
|
||||
|
||||
return state.for_each("ircd.member", event::closure_bool{[&membership, &closure]
|
||||
(const m::event &event)
|
||||
return state.for_each("ircd.member", [&membership, &closure]
|
||||
(const string_view &, const string_view &state_key, const m::event::idx &event_idx)
|
||||
{
|
||||
const string_view &membership_
|
||||
bool ret{true};
|
||||
m::get(std::nothrow, event_idx, "content", [&state_key, &membership, &closure, &ret]
|
||||
(const json::object &content)
|
||||
{
|
||||
m::membership(event)
|
||||
};
|
||||
const json::string &membership_
|
||||
{
|
||||
content.get("membership")
|
||||
};
|
||||
|
||||
if(membership && membership_ != membership)
|
||||
return true;
|
||||
if(!membership || membership_ == membership)
|
||||
{
|
||||
const m::room::id &room_id{state_key};
|
||||
ret = closure(room_id, membership_);
|
||||
}
|
||||
});
|
||||
|
||||
const m::room::id &room_id
|
||||
{
|
||||
at<"state_key"_>(event)
|
||||
};
|
||||
|
||||
return closure(room_id, membership);
|
||||
}});
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue