0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-28 00:14:07 +01:00

ircd:Ⓜ️:rooms: Add is_public() test if listed in !public.

This commit is contained in:
Jason Volk 2019-03-01 14:51:30 -08:00
parent ba2e81254b
commit c8bce8e251
3 changed files with 23 additions and 0 deletions

View file

@ -37,6 +37,7 @@ namespace ircd::m::rooms
bool for_each_public(const room::id::closure_bool &);
size_t count_public(const string_view &server = {});
bool is_public(const room::id &);
// Linkage to utils that build a publicrooms summary from room state.
void summary_chunk(const m::room &, json::stack::object &chunk);

View file

@ -2209,6 +2209,19 @@ ircd::m::rooms::for_each(const user &user,
return rooms.for_each(membership, closure);
}
bool
ircd::m::rooms::is_public(const room::id &room_id)
{
using prototype = bool (const room::id &);
static mods::import<prototype> call
{
"m_rooms", "ircd::m::rooms::is_public"
};
return call(room_id);
}
size_t
ircd::m::rooms::count_public(const string_view &server)
{

View file

@ -82,6 +82,15 @@ ircd::m::rooms::_for_each(const string_view &room_id_lb,
return state.for_each("ircd.room", room_id_lb, keys);
}
bool
IRCD_MODULE_EXPORT
ircd::m::rooms::is_public(const room::id &room_id)
{
const m::room room{public_room_id};
const m::room::state state{room};
return state.has("ircd.room", room_id);
}
size_t
ircd::m::rooms::_count_public(const string_view &server)
{