From c8bce8e251945e69efbff36072fb8f1880f90a61 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 1 Mar 2019 14:51:30 -0800 Subject: [PATCH] ircd::m::rooms: Add is_public() test if listed in !public. --- include/ircd/m/rooms.h | 1 + ircd/m.cc | 13 +++++++++++++ modules/m_rooms.cc | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/include/ircd/m/rooms.h b/include/ircd/m/rooms.h index 10dfa57c2..507bed8cd 100644 --- a/include/ircd/m/rooms.h +++ b/include/ircd/m/rooms.h @@ -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); diff --git a/ircd/m.cc b/ircd/m.cc index 399f14e26..78ba69e71 100644 --- a/ircd/m.cc +++ b/ircd/m.cc @@ -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 call + { + "m_rooms", "ircd::m::rooms::is_public" + }; + + return call(room_id); +} + size_t ircd::m::rooms::count_public(const string_view &server) { diff --git a/modules/m_rooms.cc b/modules/m_rooms.cc index 3e89d4fa9..117a19b2a 100644 --- a/modules/m_rooms.cc +++ b/modules/m_rooms.cc @@ -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) {