summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2019-02-25 15:23:27 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2019-02-25 15:23:27 +0000
commit84c0a20dfeb043f1113a6e213bc7488ef21a0432 (patch)
treeb6c96acf614f35b6ae6f9bc8e3de40ac4775b3f9 /synapse
parentMerge branch 'develop' of github.com:matrix-org/synapse into anoa/public_room... (diff)
downloadsynapse-84c0a20dfeb043f1113a6e213bc7488ef21a0432.tar.xz
Simplify call to generate_room_entry
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/room_list.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/synapse/handlers/room_list.py b/synapse/handlers/room_list.py
index 810c624c2b..69b0bc3dd1 100644
--- a/synapse/handlers/room_list.py
+++ b/synapse/handlers/room_list.py
@@ -300,24 +300,24 @@ class RoomListHandler(BaseHandler):
             # We've already got enough, so lets just drop it.
             return
 
-        if from_federation:
-            result = yield self.generate_room_entry(room_id,
-                self.config.allow_non_federated_in_public_rooms,
-                num_joined_users)
-        else:
-            result = yield self.generate_room_entry(room_id, True, num_joined_users)
-
-        if result and _matches_room_entry(result, search_filter):
+        result = yield self.generate_room_entry(room_id,
+            num_joined_users)
+
+        if from_federation and not self.config.allow_non_federated_in_public_rooms:
+            if result["m.federate"] = False:
+                # This is a non-federating room and the config has chosen not
+                # to show these rooms to other servers
+                chunk.append(None)
+        else if result and _matches_room_entry(result, search_filter):
             chunk.append(result)
 
     @cachedInlineCallbacks(num_args=2, cache_context=True)
-    def generate_room_entry(self, room_id, allow_non_federated, num_joined_users,
+    def generate_room_entry(self, room_id, num_joined_users,
                             cache_context, with_alias=True, allow_private=False):
         """Returns the entry for a room
 
         Args:
             room_id (str): The room's ID.
-            allow_non_federated (bool): Whether rooms with federation
             disabled should be shown.
             num_joined_users (int): Number of users in the room.
             cache_context: Information for cached responses.
@@ -364,13 +364,9 @@ class RoomListHandler(BaseHandler):
             if not allow_private and join_rule and join_rule != JoinRules.PUBLIC:
                 defer.returnValue(None)
 
-        if not allow_non_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)
+        # Return whether this room is open to federation users or not
+        create_event = current_state.get((EventTypes.Create, ""))
+        result["m.federate"] = create_event.content.get("m.federate", True)
 
         if with_alias:
             aliases = yield self.store.get_aliases_for_room(