mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 08:23:56 +01:00
ircd:Ⓜ️:rooms: Simplify interface.
This commit is contained in:
parent
160927e119
commit
f24c7c2e82
2 changed files with 0 additions and 40 deletions
|
@ -38,13 +38,6 @@ namespace ircd::m::rooms
|
|||
/// the only options patterns.
|
||||
struct ircd::m::rooms::each_opts
|
||||
{
|
||||
/// If set: select rooms for this user.
|
||||
m::user user;
|
||||
|
||||
/// If user is set, and this is set: select the membership that user
|
||||
/// has in the room.
|
||||
string_view membership;
|
||||
|
||||
/// If set, seek to this room_id or lower-bound to the closest room_id.
|
||||
string_view key;
|
||||
|
||||
|
@ -58,13 +51,8 @@ struct ircd::m::rooms::each_opts
|
|||
/// for-each protocol: return true to continue, false to break.
|
||||
room::id::closure_bool closure;
|
||||
|
||||
/// Alternative closure when selecting a user.
|
||||
user::rooms::closure_bool user_closure;
|
||||
|
||||
each_opts(room::id::closure_bool);
|
||||
each_opts(const string_view &key, room::id::closure_bool);
|
||||
each_opts(const m::user &user, user::rooms::closure_bool);
|
||||
each_opts(const m::user &user, const string_view &membership, user::rooms::closure_bool);
|
||||
each_opts() = default;
|
||||
};
|
||||
|
||||
|
@ -80,22 +68,6 @@ ircd::m::rooms::each_opts::each_opts(const string_view &key,
|
|||
,closure{std::move(closure)}
|
||||
{}
|
||||
|
||||
inline
|
||||
ircd::m::rooms::each_opts::each_opts(const m::user &user,
|
||||
user::rooms::closure_bool user_closure)
|
||||
:user{user}
|
||||
,user_closure{std::move(user_closure)}
|
||||
{}
|
||||
|
||||
inline
|
||||
ircd::m::rooms::each_opts::each_opts(const m::user &user,
|
||||
const string_view &membership,
|
||||
user::rooms::closure_bool user_closure)
|
||||
:user{user}
|
||||
,membership{membership}
|
||||
,user_closure{std::move(user_closure)}
|
||||
{}
|
||||
|
||||
template<class... args>
|
||||
bool
|
||||
ircd::m::rooms::for_each(args&&... a)
|
||||
|
|
|
@ -60,18 +60,6 @@ bool
|
|||
IRCD_MODULE_EXPORT
|
||||
ircd::m::rooms::for_each(const each_opts &opts)
|
||||
{
|
||||
if(opts.user.user_id)
|
||||
{
|
||||
const m::user::rooms rooms{opts.user};
|
||||
return rooms.for_each(opts.membership, m::user::rooms::closure_bool{[&opts]
|
||||
(const m::room &room, const string_view &membership)
|
||||
{
|
||||
return opts.user_closure?
|
||||
opts.user_closure(room, membership):
|
||||
opts.closure(room.room_id);
|
||||
}});
|
||||
}
|
||||
|
||||
if(opts.public_rooms)
|
||||
return _for_each_public(opts.key, opts.closure);
|
||||
|
||||
|
|
Loading…
Reference in a new issue