summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Cloke <patrickc@matrix.org>2022-05-26 16:07:21 -0400
committerPatrick Cloke <patrickc@matrix.org>2022-06-13 09:57:05 -0400
commit7c320b79bfe43b70774716f9b3085de23a73d376 (patch)
tree6bdda8f362bbb3b29332c8e1e6e040b93608fe59
parentAdd a ranged receipts table and insert into it. (diff)
downloadsynapse-7c320b79bfe43b70774716f9b3085de23a73d376.tar.xz
Use the ranged receipts table when fetching receipts for /sync.
-rw-r--r--synapse/storage/databases/main/receipts.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/synapse/storage/databases/main/receipts.py b/synapse/storage/databases/main/receipts.py
index 7c586cf8f3..c2381017b0 100644
--- a/synapse/storage/databases/main/receipts.py
+++ b/synapse/storage/databases/main/receipts.py
@@ -380,7 +380,7 @@ class ReceiptsWorkerStore(SQLBaseStore):
         def f(txn: LoggingTransaction) -> List[Dict[str, Any]]:
             if from_key:
                 sql = """
-                    SELECT * FROM receipts_linearized WHERE
+                    SELECT * FROM receipts_ranged WHERE
                     stream_id > ? AND stream_id <= ? AND
                 """
                 clause, args = make_in_list_sql_clause(
@@ -390,7 +390,7 @@ class ReceiptsWorkerStore(SQLBaseStore):
                 txn.execute(sql + clause, [from_key, to_key] + list(args))
             else:
                 sql = """
-                    SELECT * FROM receipts_linearized WHERE
+                    SELECT * FROM receipts_ranged WHERE
                     stream_id <= ? AND
                 """
 
@@ -417,10 +417,11 @@ class ReceiptsWorkerStore(SQLBaseStore):
 
             # The content is of the form:
             # {"$foo:bar": { "read": { "@user:host": <receipt> }, .. }, .. }
-            event_entry = room_event["content"].setdefault(row["event_id"], {})
+            event_entry = room_event["content"].setdefault(row["end_event_id"], {})
             receipt_type = event_entry.setdefault(row["receipt_type"], {})
 
             receipt_type[row["user_id"]] = db_to_json(row["data"])
+            receipt_type[row["user_id"]]["start_event_id"] = row["start_event_id"]
 
         results = {
             room_id: [results[room_id]] if room_id in results else []