-
Notifications
You must be signed in to change notification settings - Fork 520
Fix bug where ephemeral events were not filtered by room ID #19002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
77ab231
b9ffb45
097c483
d98a0ba
62c1eac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -553,7 +553,7 @@ async def ephemeral_by_room( | |
| Returns: | ||
| A tuple of the now StreamToken, updated to reflect the which typing | ||
| events are included, and a dict mapping from room_id to a list of | ||
| typing events for that room. | ||
| ephemeral events for that room. | ||
| """ | ||
|
|
||
| sync_config = sync_result_builder.sync_config | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
||
|
|
@@ -2734,9 +2728,13 @@ async def _generate_room_entry( | |
| ) | ||
| ) | ||
|
|
||
| ephemeral = await sync_config.filter_collection.filter_room_ephemeral( | ||
| ephemeral | ||
| ) | ||
| ephemeral = [ | ||
| # copy fields from each `event` into a new dict, excluding `room_id` | ||
|
MadLittleMods marked this conversation as resolved.
Outdated
|
||
| {k: v for (k, v) in event.items() if k != "room_id"} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 But now we filter The other fix where we pass in the the full EDU to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't see a functional change, and I think the conceptual change is OK?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want to exclude the
room_id? (feels like some comment context is missing)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is explained in the Complement tests -> matrix-org/complement#807
We should explain this in the comments here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve added more context to the comment. Let me know if it’s enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was updated to the following:
synapse/synapse/handlers/sync.py
Lines 2732 to 2736 in 1d2ddbc
I think we could explain more about where
room_idis coming from in the first place since it isn't desired when passing it back to the client.Are we sure this even needs to happen? The server spec says EDU's don't include a
room_id:Overall, EDU's are just not clear to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anoadragon453 responded below (threading problems) -> #19002 (comment)