0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-29 00:03:45 +02:00

ircd:Ⓜ️:rooms: Add room::lonly() related to interface.

This commit is contained in:
Jason Volk 2019-08-13 04:43:04 -07:00
parent 6333c94fe0
commit 74cef5d74d
3 changed files with 31 additions and 6 deletions

View file

@ -87,4 +87,12 @@ struct ircd::m::rooms::opts
/// at the same or next key, and continue indefinitely. By false default,
/// when a room_id is given a for_each() will have 0 or 1 iterations.
bool lower_bound {false};
/// Local-only (see room/room.h). If set to true, results are limited to
/// rooms where no other server is joined to the room.
bool local_only {false};
/// Non-lonly (see room/room.h). If set to true, rooms where no
/// other server is joined to the room are filtered from the results.
bool remote_joined_only {false};
};

View file

@ -7573,7 +7573,9 @@ console_cmd__rooms(opt &out, const string_view &line)
const string_view &server
{
param["server"] != "*"?
param["server"] != "*" &&
param["server"] != "remote_joined_only" &&
param["server"] != "local_only"?
param["server"]:
string_view{}
};
@ -7592,14 +7594,21 @@ console_cmd__rooms(opt &out, const string_view &line)
string_view{}
};
auto limit
{
param.at("limit", 32L)
};
m::rooms::opts opts;
opts.server = server;
opts.search_term = search_term;
if(param["server"] == "remote_joined_only")
opts.remote_joined_only = true;
if(param["server"] == "local_only")
opts.local_only = true;
auto limit
{
param.at("limit", 64L)
};
m::rooms::for_each(opts, [&limit, &out]
(const m::room::id &room_id) -> bool
{

View file

@ -70,6 +70,14 @@ ircd::m::rooms::for_each(const opts &opts,
if(room_id < opts.room_id)
return;
if(opts.remote_joined_only)
if(room(room_id).lonly())
return;
if(opts.local_only)
if(!room(room_id).lonly())
return;
if(opts.server && !opts.summary)
if(opts.server != room_id.host())
return;