Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/17589.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Correctly track read receipts that should be sent down in experimental sliding sync.
30 changes: 16 additions & 14 deletions synapse/handlers/sliding_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -2858,6 +2858,7 @@ async def get_account_data_extension_response(
account_data_by_room_map=account_data_by_room_map,
)

@trace
async def get_receipts_extension_response(
self,
sync_config: SlidingSyncConfig,
Expand Down Expand Up @@ -2966,24 +2967,25 @@ async def get_receipts_extension_response(
# from that room but we only want to include receipts for events
# in the timeline to avoid bloating and blowing up the sync response
# as the number of users in the room increases. (this behavior is part of the spec)
for room_id in initial_rooms:
room_result = actual_room_response_map.get(room_id)
if room_result is None:
continue

relevant_event_ids = [
event.event_id for event in room_result.timeline_events
]

# TODO: In the future, it would be good to fetch less receipts
# out of the database in the first place but we would need to
# add a new `event_id` index to `receipts_linearized`.
initial_receipts = await self.store.get_linearized_receipts_for_room(
room_id=room_id,
initial_rooms = {
room_id
for room_id in initial_rooms
if room_id in actual_room_response_map
}
if initial_rooms:
initial_receipts = await self.store.get_linearized_receipts_for_rooms(
room_ids=initial_rooms,
to_key=to_token.receipt_key,
)

for receipt in initial_receipts:
relevant_event_ids = [
event.event_id
for event in actual_room_response_map[
receipt["room_id"]
].timeline_events
]

content = {
event_id: content_value
for event_id, content_value in receipt["content"].items()
Expand Down
Loading