summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2019-02-22 12:11:43 +0000
committerErik Johnston <erik@matrix.org>2019-02-25 15:04:46 +0000
commite4b078a6004ea34684c27056825346178c22aa0f (patch)
tree402c7129fa3f7a9923bc87ea70c4591ec889fa47 /synapse/handlers
parentMerge branch 'release-v0.33.8' (diff)
downloadsynapse-e4b078a6004ea34684c27056825346178c22aa0f.tar.xz
Config option to prevent showing non-fed rooms in fed /publicRooms
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/room_list.py17
1 files changed, 15 insertions, 2 deletions
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