From 833883ee8a45f606e8328be0cb46c28cdac56cdb Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 10 Sep 2020 19:51:08 +0100 Subject: [PATCH] Query ThirdPartyEventRules while trying to add to the public room dir --- synapse/handlers/directory.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/synapse/handlers/directory.py b/synapse/handlers/directory.py index 46826eb784..fbbd3d4a66 100644 --- a/synapse/handlers/directory.py +++ b/synapse/handlers/directory.py @@ -46,6 +46,7 @@ class DirectoryHandler(BaseHandler): self.config = hs.config self.enable_room_list_search = hs.config.enable_room_list_search self.require_membership = hs.config.require_membership_for_aliases + self.third_party_event_rules = hs.get_third_party_event_rules() self.federation = hs.get_federation_client() hs.get_federation_registry().register_query_handler( @@ -454,6 +455,15 @@ class DirectoryHandler(BaseHandler): # per alias creation rule? raise SynapseError(403, "Not allowed to publish room") + # Check if publishing is blocked by a third party module + allowed_by_third_party_rules = await ( + self.third_party_event_rules.check_room_can_be_added_to_public_rooms_directory( + room_id + ) + ) + if not allowed_by_third_party_rules: + raise SynapseError(403, "Not allowed to publish room") + await self.store.set_room_is_public(room_id, making_public) async def edit_published_appservice_room_list(