summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2015-06-18 14:15:20 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2015-06-18 14:15:20 +0100
commit7c5315b1a8764b3e2080fba306e6919111dcdced (patch)
tree86476e45fe11f9012a721f459cf98e568418a144
parentRename get_public_room_ids() to get_published_room_ids() (diff)
downloadsynapse-7c5315b1a8764b3e2080fba306e6919111dcdced.tar.xz
Since store.get_rooms() is only ever called with is_public=True, just fold that inline + rename the method to .get_published_rooms()
-rw-r--r--synapse/handlers/room.py2
-rw-r--r--synapse/handlers/sync.py6
-rw-r--r--synapse/storage/room.py10
-rw-r--r--tests/storage/test_room.py8
4 files changed, 11 insertions, 15 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index 46fe517957..39e3e1d22b 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -533,7 +533,7 @@ class RoomListHandler(BaseHandler):
 
     @defer.inlineCallbacks
     def get_published_rooms(self):
-        chunk = yield self.store.get_rooms(is_public=True)
+        chunk = yield self.store.get_published_rooms()
         results = yield defer.gatherResults(
             [
                 self.store.get_users_in_room(room["room_id"])
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py
index bd8c603681..317378bca4 100644
--- a/synapse/handlers/sync.py
+++ b/synapse/handlers/sync.py
@@ -147,8 +147,7 @@ class SyncHandler(BaseHandler):
             membership_list=[Membership.INVITE, Membership.JOIN]
         )
 
-        # TODO (mjark): Does public mean "published"?
-        published_rooms = yield self.store.get_rooms(is_public=True)
+        published_rooms = yield self.store.get_published_rooms()
         published_room_ids = set(r["room_id"] for r in published_rooms)
 
         rooms = []
@@ -231,8 +230,7 @@ class SyncHandler(BaseHandler):
         rm_handler = self.hs.get_handlers().room_member_handler
         room_ids = yield rm_handler.get_joined_rooms_for_user(sync_config.user)
 
-        # TODO (mjark): Does public mean "published"?
-        published_rooms = yield self.store.get_rooms(is_public=True)
+        published_rooms = yield self.store.get_published_rooms()
         published_room_ids = set(r["room_id"] for r in published_rooms)
 
         room_events, _ = yield self.store.get_room_events_stream(
diff --git a/synapse/storage/room.py b/synapse/storage/room.py
index c64cb9bbd1..9d6ff53fac 100644
--- a/synapse/storage/room.py
+++ b/synapse/storage/room.py
@@ -86,11 +86,9 @@ class RoomStore(SQLBaseStore):
         )
 
     @defer.inlineCallbacks
-    def get_rooms(self, is_public):
-        """Retrieve a list of all public rooms.
+    def get_published_rooms(self):
+        """Retrieve a list of all published rooms.
 
-        Args:
-            is_public (bool): True if the rooms returned should be public.
         Returns:
             A list of room dicts containing at least a "room_id" key, a
             "topic" key if one is set, and a "name" key if one is set
@@ -119,14 +117,14 @@ class RoomStore(SQLBaseStore):
                 " FROM rooms AS r"
                 " LEFT JOIN (%(topic)s) AS t ON t.room_id = r.room_id"
                 " LEFT JOIN (%(name)s) AS n ON n.room_id = r.room_id"
-                " WHERE r.is_public = ?"
+                " WHERE r.is_public"
                 " GROUP BY r.room_id"
             ) % {
                 "topic": topic_subquery,
                 "name": name_subquery,
             }
 
-            txn.execute(sql, (is_public,))
+            txn.execute(sql)
 
             rows = txn.fetchall()
 
diff --git a/tests/storage/test_room.py b/tests/storage/test_room.py
index ab7625a3ca..44cf2ee853 100644
--- a/tests/storage/test_room.py
+++ b/tests/storage/test_room.py
@@ -52,10 +52,10 @@ class RoomStoreTestCase(unittest.TestCase):
         )
 
     @defer.inlineCallbacks
-    def test_get_rooms(self):
-        # get_rooms does an INNER JOIN on the room_aliases table :(
+    def test_get_published_rooms(self):
+        # get_published_rooms does an INNER JOIN on the room_aliases table :(
 
-        rooms = yield self.store.get_rooms(is_public=True)
+        rooms = yield self.store.get_published_rooms()
         # Should be empty before we add the alias
         self.assertEquals([], rooms)
 
@@ -65,7 +65,7 @@ class RoomStoreTestCase(unittest.TestCase):
             servers=["test"]
         )
 
-        rooms = yield self.store.get_rooms(is_public=True)
+        rooms = yield self.store.get_published_rooms()
 
         self.assertEquals(1, len(rooms))
         self.assertEquals({