summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
Diffstat (limited to 'synapse')
-rw-r--r--synapse/config/room_directory.py11
-rw-r--r--synapse/handlers/room_list.py17
2 files changed, 26 insertions, 2 deletions
diff --git a/synapse/config/room_directory.py b/synapse/config/room_directory.py
index 9da13ab11b..08d1d26e58 100644
--- a/synapse/config/room_directory.py
+++ b/synapse/config/room_directory.py
@@ -27,6 +27,10 @@ class RoomDirectoryConfig(Config):
             for rule in alias_creation_rules
         ]
 
+        self.allow_non_federated_in_public_rooms = config.get(
+            "allow_non_federated_in_public_rooms", True,
+        )
+
     def default_config(self, config_dir_path, server_name, **kwargs):
         return """
         # The `alias_creation` option controls who's allowed to create aliases
@@ -42,6 +46,13 @@ class RoomDirectoryConfig(Config):
             - user_id: "*"
               alias: "*"
               action: allow
+
+        # Specify whether rooms that only allow local users to join should be
+        # shown in the federation public room directory.
+        # 
+        # Note that this does not affect the room directory shown to users on
+        # this homeserver, only those on other homeservers.
+        #allow_non_federated_in_public_rooms: True
         """
 
     def is_alias_creation_allowed(self, user_id, alias):
diff --git a/synapse/handlers/room_list.py b/synapse/handlers/room_list.py
index dc88620885..47aeeb1d88 100644
--- a/synapse/handlers/room_list.py
+++ b/synapse/handlers/room_list.py
@@ -47,6 +47,7 @@ class RoomListHandler(BaseHandler):
         self.response_cache = ResponseCache(hs, "room_list")
         self.remote_response_cache = ResponseCache(hs, "remote_room_list",
                                                    timeout_ms=30 * 1000)
+        self.config = hs.get_config()
 
     def get_local_public_room_list(self, limit=None, since_token=None,
                                    search_filter=None,
@@ -286,14 +287,16 @@ class RoomListHandler(BaseHandler):
             # We've already got enough, so lets just drop it.
             return
 
-        result = yield self.generate_room_entry(room_id, num_joined_users)
+        result = yield self.generate_room_entry(room_id, num_joined_users,
+            allow_federated=self.config.allow_non_federated_in_public_rooms)
 
         if result and _matches_room_entry(result, search_filter):
             chunk.append(result)
 
     @cachedInlineCallbacks(num_args=1, cache_context=True)
     def generate_room_entry(self, room_id, num_joined_users, cache_context,
-                            with_alias=True, allow_private=False):
+                            with_alias=True, allow_private=False,
+                            allow_federated=True):
         """Returns the entry for a room
         """
         result = {
@@ -308,6 +311,7 @@ class RoomListHandler(BaseHandler):
         event_map = yield self.store.get_events([
             event_id for key, event_id in iteritems(current_state_ids)
             if key[0] in (
+                EventTypes.Create,
                 EventTypes.JoinRules,
                 EventTypes.Name,
                 EventTypes.Topic,
@@ -324,12 +328,21 @@ class RoomListHandler(BaseHandler):
         }
 
         # Double check that this is actually a public room.
+
         join_rules_event = current_state.get((EventTypes.JoinRules, ""))
         if join_rules_event:
             join_rule = join_rules_event.content.get("join_rule", None)
             if not allow_private and join_rule and join_rule != JoinRules.PUBLIC:
                 defer.returnValue(None)
 
+        if not allow_federated:
+            # Disallow non-federated from appearing
+            create_event = current_state.get((EventTypes.Create, ""))
+            if create_event:
+                federate = create_event.content.get("m.federate", True)
+                if federate == False:
+                    defer.returnValue(None)
+
         if with_alias:
             aliases = yield self.store.get_aliases_for_room(
                 room_id, on_invalidate=cache_context.invalidate