summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-07-08 15:35:00 +0100
committerErik Johnston <erik@matrix.org>2015-07-08 15:35:00 +0100
commitaf812b68ddbd1a69a8c98c463248d000633b075f (patch)
tree39b37e90cc1c9eb5dd0343485b585ff61af4a539 /synapse/handlers
parentSplit receipt events up into one per room (diff)
downloadsynapse-af812b68ddbd1a69a8c98c463248d000633b075f.tar.xz
Add a cache to fetching of receipt streams
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/receipts.py31
1 files changed, 7 insertions, 24 deletions
diff --git a/synapse/handlers/receipts.py b/synapse/handlers/receipts.py
index b7567b9ead..053ed84805 100644
--- a/synapse/handlers/receipts.py
+++ b/synapse/handlers/receipts.py
@@ -37,8 +37,7 @@ class ReceiptsHandler(BaseHandler):
             "m.receipt", self._received_remote_receipt
         )
 
-        # self._earliest_cached_serial = 0
-        # self._rooms_to_latest_serial = {}
+        self._receipt_cache = None
 
     @defer.inlineCallbacks
     def received_client_receipt(self, room_id, receipt_type, user_id,
@@ -162,17 +161,9 @@ class ReceiptEventSource(object):
 
         rooms = yield self.store.get_rooms_for_user(user.to_string())
         rooms = [room.room_id for room in rooms]
-        events = []
-        for room_id in rooms:
-            content = yield self.store.get_linearized_receipts_for_room(
-                room_id, from_key, to_key
-            )
-            if content:
-                events.append({
-                    "type": "m.receipt",
-                    "room_id": room_id,
-                    "content": content,
-                })
+        events = yield self.store.get_linearized_receipts_for_rooms(
+            rooms, from_key, to_key
+        )
 
         defer.returnValue((events, to_key))
 
@@ -190,16 +181,8 @@ class ReceiptEventSource(object):
 
         rooms = yield self.store.get_rooms_for_user(user.to_string())
         rooms = [room.room_id for room in rooms]
-        events = []
-        for room_id in rooms:
-            content = yield self.store.get_linearized_receipts_for_room(
-                room_id, from_key, to_key
-            )
-            if content:
-                events.append({
-                    "type": "m.receipt",
-                    "room_id": room_id,
-                    "content": content,
-                })
+        events = yield self.store.get_linearized_receipts_for_rooms(
+            rooms, from_key, to_key
+        )
 
         defer.returnValue((events, to_key))