Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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/19002.bugifx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug where ephemeral events were not filtered by room ID. Contributed by @frastefanini.
20 changes: 9 additions & 11 deletions synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,8 @@ async def ephemeral_by_room(
ephemeral_by_room: JsonDict = {}

for event in typing:
# we want to exclude the room_id from the event, but modifying the
# result returned by the event source is poor form (it might cache
# the object)
room_id = event["room_id"]
event_copy = {k: v for (k, v) in event.items() if k != "room_id"}
ephemeral_by_room.setdefault(room_id, []).append(event_copy)
ephemeral_by_room.setdefault(room_id, []).append(event)

receipt_key = (
since_token.receipt_key
Expand All @@ -603,9 +599,7 @@ async def ephemeral_by_room(

for event in receipts:
room_id = event["room_id"]
# exclude room id, as above
event_copy = {k: v for (k, v) in event.items() if k != "room_id"}
ephemeral_by_room.setdefault(room_id, []).append(event_copy)
ephemeral_by_room.setdefault(room_id, []).append(event)

return now_token, ephemeral_by_room

Expand Down Expand Up @@ -2734,9 +2728,13 @@ async def _generate_room_entry(
)
)

ephemeral = await sync_config.filter_collection.filter_room_ephemeral(
ephemeral
)
ephemeral = [
# exclude room id
{k: v for (k, v) in event.items() if k != "room_id"}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main difference I see from the previous implementation is that we previously we only removed the room_id from typing and receipt EDU.

But now we filter room_id from everything. I don't really see context for whether that is actually desired.


The other fix where we pass in the the full EDU to filter_room_ephemeral(...) makes sense

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ephemeral_by_room should only return typing and receipt events that are tied to a room. If we introduce a new room-linked EDU type, then I suspect that will also need the room_id field removed before being sent down /sync.

I don't see a functional change, and I think the conceptual change is OK?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explaining 👍 I didn't pick up on the tenuous connection.

for event in await sync_config.filter_collection.filter_room_ephemeral(
ephemeral
)
]

if not (
always_include
Expand Down
Loading