mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 15:30:52 +01:00
ircd:Ⓜ️:users: Add lower_bounding for_each; prefix search to users console cmd.
This commit is contained in:
parent
ba70c1b128
commit
16ac997220
3 changed files with 25 additions and 3 deletions
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
namespace ircd::m::users
|
namespace ircd::m::users
|
||||||
{
|
{
|
||||||
|
bool for_each(const string_view &id_lower_bound, const user::closure_bool &);
|
||||||
bool for_each(const user::closure_bool &);
|
bool for_each(const user::closure_bool &);
|
||||||
void for_each(const user::closure &);
|
void for_each(const user::closure &);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1567,13 +1567,20 @@ ircd::m::users::for_each(const user::closure &closure)
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ircd::m::users::for_each(const user::closure_bool &closure)
|
ircd::m::users::for_each(const user::closure_bool &closure)
|
||||||
|
{
|
||||||
|
return for_each(string_view{}, closure);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ircd::m::users::for_each(const string_view &lower_bound,
|
||||||
|
const user::closure_bool &closure)
|
||||||
{
|
{
|
||||||
const m::room::state state
|
const m::room::state state
|
||||||
{
|
{
|
||||||
user::users
|
user::users
|
||||||
};
|
};
|
||||||
|
|
||||||
return state.for_each("ircd.user", m::room::state::keys_bool{[&closure]
|
return state.for_each("ircd.user", lower_bound, m::room::state::keys_bool{[&closure]
|
||||||
(const string_view &user_id)
|
(const string_view &user_id)
|
||||||
{
|
{
|
||||||
const m::user &user
|
const m::user &user
|
||||||
|
|
|
@ -7239,11 +7239,25 @@ console_cmd__user__events__count(opt &out, const string_view &line)
|
||||||
bool
|
bool
|
||||||
console_cmd__users(opt &out, const string_view &line)
|
console_cmd__users(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
m::users::for_each([&out]
|
const params param{line, " ",
|
||||||
|
{
|
||||||
|
"prefix"
|
||||||
|
}};
|
||||||
|
|
||||||
|
const auto prefix
|
||||||
|
{
|
||||||
|
param.at("prefix", string_view{})
|
||||||
|
};
|
||||||
|
|
||||||
|
m::users::for_each(prefix, m::user::closure_bool{[&out, &prefix]
|
||||||
(const m::user &user)
|
(const m::user &user)
|
||||||
{
|
{
|
||||||
|
if(prefix && !startswith(user.user_id, prefix))
|
||||||
|
return false;
|
||||||
|
|
||||||
out << user.user_id << std::endl;
|
out << user.user_id << std::endl;
|
||||||
});
|
return true;
|
||||||
|
}});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue