Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 4fe707a

Browse files
committed
Properly replication the thread_id on receipts.
1 parent 3a5862d commit 4fe707a

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

synapse/replication/tcp/streams/_base.py

+1
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ class ReceiptsStreamRow:
361361
receipt_type: str
362362
user_id: str
363363
event_id: str
364+
thread_id: Optional[str]
364365
data: dict
365366

366367
NAME = "receipts"

synapse/storage/databases/main/receipts.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,9 @@ def _get_users_sent_receipts_between_txn(txn: LoggingTransaction) -> List[str]:
540540

541541
async def get_all_updated_receipts(
542542
self, instance_name: str, last_id: int, current_id: int, limit: int
543-
) -> Tuple[List[Tuple[int, list]], int, bool]:
543+
) -> Tuple[
544+
List[Tuple[int, Tuple[str, str, str, str, Optional[str], JsonDict]]], int, bool
545+
]:
544546
"""Get updates for receipts replication stream.
545547
546548
Args:
@@ -567,9 +569,13 @@ async def get_all_updated_receipts(
567569

568570
def get_all_updated_receipts_txn(
569571
txn: LoggingTransaction,
570-
) -> Tuple[List[Tuple[int, list]], int, bool]:
572+
) -> Tuple[
573+
List[Tuple[int, Tuple[str, str, str, str, Optional[str], JsonDict]]],
574+
int,
575+
bool,
576+
]:
571577
sql = """
572-
SELECT stream_id, room_id, receipt_type, user_id, event_id, data
578+
SELECT stream_id, room_id, receipt_type, user_id, event_id, thread_id, data
573579
FROM receipts_linearized
574580
WHERE ? < stream_id AND stream_id <= ?
575581
ORDER BY stream_id ASC
@@ -578,8 +584,8 @@ def get_all_updated_receipts_txn(
578584
txn.execute(sql, (last_id, current_id, limit))
579585

580586
updates = cast(
581-
List[Tuple[int, list]],
582-
[(r[0], r[1:5] + (db_to_json(r[5]),)) for r in txn],
587+
List[Tuple[int, Tuple[str, str, str, str, Optional[str], JsonDict]]],
588+
[(r[0], r[1:6] + (db_to_json(r[6]),)) for r in txn],
583589
)
584590

585591
limited = False

tests/replication/tcp/streams/test_receipts.py

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def test_receipt(self):
4848
self.assertEqual("m.read", row.receipt_type)
4949
self.assertEqual(USER_ID, row.user_id)
5050
self.assertEqual("$event:blue", row.event_id)
51+
self.assertIsNone(row.thread_id)
5152
self.assertEqual({"a": 1}, row.data)
5253

5354
# Now let's disconnect and insert some data.

0 commit comments

Comments
 (0)