summary refs log tree commit diff
path: root/synapse/handlers/receipts.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-07-08 10:54:01 +0100
committerErik Johnston <erik@matrix.org>2015-07-08 11:02:04 +0100
commit87311d1b8cc648400dfce5db8a7fed46abbeb963 (patch)
treecd3ef2c36c70eaaf92203ae57d0489f5674209bc /synapse/handlers/receipts.py
parentFix test. (diff)
downloadsynapse-87311d1b8cc648400dfce5db8a7fed46abbeb963.tar.xz
Hook up receipts to v1 initialSync
Diffstat (limited to 'synapse/handlers/receipts.py')
-rw-r--r--synapse/handlers/receipts.py45
1 files changed, 44 insertions, 1 deletions
diff --git a/synapse/handlers/receipts.py b/synapse/handlers/receipts.py
index 94f0810057..f6cde30e63 100644
--- a/synapse/handlers/receipts.py
+++ b/synapse/handlers/receipts.py
@@ -133,6 +133,24 @@ class ReceiptsHandler(BaseHandler):
                     },
                 )
 
+    @defer.inlineCallbacks
+    def get_receipts_for_room(self, room_id, to_key):
+        result = yield self.store.get_linearized_receipts_for_room(
+            room_id, None, to_key
+        )
+
+        if not result:
+            defer.returnValue([])
+
+        event = {
+            "type": "m.receipt",
+            "content": {
+                room_id: result,
+            },
+        }
+
+        defer.returnValue([event])
+
 
 class ReceiptEventSource(object):
     def __init__(self, hs):
@@ -168,4 +186,29 @@ class ReceiptEventSource(object):
 
     @defer.inlineCallbacks
     def get_pagination_rows(self, user, config, key):
-        defer.returnValue(([{}], 0))
+        to_key = int(config.from_key)
+
+        if config.to_key:
+            from_key = int(config.to_key)
+        else:
+            from_key = None
+
+        rooms = yield self.store.get_rooms_for_user(user.to_string())
+        rooms = [room.room_id for room in rooms]
+        content = {}
+        for room_id in rooms:
+            result = yield self.store.get_linearized_receipts_for_room(
+                room_id, from_key, to_key
+            )
+            if result:
+                content[room_id] = result
+
+        if not content:
+            defer.returnValue(([], to_key))
+
+        event = {
+            "type": "m.receipt",
+            "content": content,
+        }
+
+        defer.returnValue(([event], to_key))