0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00

ircd:Ⓜ️:room: Add any_user() convenience.

This commit is contained in:
Jason Volk 2019-04-12 04:42:18 -07:00
parent 8e5c858697
commit 7d27126f96
2 changed files with 21 additions and 0 deletions

View file

@ -83,6 +83,7 @@ struct ircd::m::room
string_view membership(const mutable_buffer &out, const m::id::user &) const;
bool visible(const string_view &mxid, const m::event *const & = nullptr) const;
string_view join_rule(const mutable_buffer &out) const;
id::user::buf any_user(const string_view &host, const string_view &membership = "join") const;
bool join_rule(const string_view &rule) const;
bool lonly() const;

View file

@ -325,6 +325,26 @@ ircd::m::room::index(const room::id &room_id,
// room::room
//
ircd::m::id::user::buf
ircd::m::room::any_user(const string_view &host,
const string_view &membership)
const
{
user::id::buf ret;
const members members{*this};
members.for_each(membership, members::closure_bool{[&host, &ret]
(const id::user &user_id)
{
if(host && user_id.host() != host)
return true;
ret = user_id;
return false;
}});
return ret;
}
/// Test of the join_rule of the room is the argument.
bool
ircd::m::room::join_rule(const string_view &rule)