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

Implement MSC3827: Filtering of /publicRooms by room type #13031

Merged
merged 38 commits into from
Jun 29, 2022

Conversation

SimonBrandner
Copy link
Contributor

@SimonBrandner SimonBrandner commented Jun 12, 2022

Implement MSC3827: Filtering of /publicRooms by room type
Towards element-hq/element-meta#338


Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
@SimonBrandner SimonBrandner marked this pull request as ready for review June 19, 2022 14:42
@SimonBrandner SimonBrandner requested a review from a team as a code owner June 19, 2022 14:42
Copy link
Contributor

@squahtx squahtx left a comment

Choose a reason for hiding this comment

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

As a follow on for another time: Now that room_stats_state contains room_type, there are one or two places where we can avoid an event fetch. eg. if we make get_room_with_stats return room_type, we can avoid fetching the m.room.create event in RoomSummaryHandler._build_room_entry.

synapse/api/constants.py Show resolved Hide resolved
synapse/handlers/room_list.py Outdated Show resolved Hide resolved
synapse/handlers/stats.py Outdated Show resolved Hide resolved
synapse/storage/databases/main/room.py Outdated Show resolved Hide resolved
synapse/storage/databases/main/room.py Outdated Show resolved Hide resolved
synapse/storage/databases/main/room.py Outdated Show resolved Hide resolved
synapse/storage/databases/main/room.py Outdated Show resolved Hide resolved
synapse/storage/databases/main/stats.py Outdated Show resolved Hide resolved
tests/rest/client/test_rooms.py Outdated Show resolved Hide resolved
tests/rest/client/test_rooms.py Show resolved Hide resolved
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
SimonBrandner and others added 9 commits June 29, 2022 06:18
Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Copy link
Contributor

@squahtx squahtx left a comment

Choose a reason for hiding this comment

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

One last comment, otherwise it's looking really good!

synapse/storage/databases/main/room.py Outdated Show resolved Hide resolved
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
Copy link
Contributor

@squahtx squahtx left a comment

Choose a reason for hiding this comment

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

Looks good!

I missed another small thing earlier - the docstring for test_background_add_room_type_column needs an update.

tests/storage/databases/main/test_room.py Outdated Show resolved Hide resolved
Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
@SimonBrandner
Copy link
Contributor Author

Looks good!

I missed another small thing earlier - the docstring for test_background_add_room_type_column needs an update.

Thanks!

@SimonBrandner SimonBrandner reopened this Jun 29, 2022
@squahtx squahtx enabled auto-merge (squash) June 29, 2022 16:30
@squahtx squahtx merged commit 13e359a into matrix-org:develop Jun 29, 2022
@SimonBrandner SimonBrandner deleted the SimonBrandner/feat/msc3827 branch June 29, 2022 17:13
@clokep
Copy link
Member

clokep commented Jun 29, 2022

we can avoid fetching the m.room.create event in RoomSummaryHandler._build_room_entry.

You figured out my plan with adding this here! 🎉

(Seems this got filed as #13130.)

Comment on lines +1625 to +1627
async def _background_add_room_type_column(
self, progress: JsonDict, batch_size: int
) -> int:
Copy link
Member

Choose a reason for hiding this comment

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

Not really sure where to make this thread, so I'll do it here (I didn't see this previously discussed on the PR, but do let me know if I missed it!)

Since this is a background update I'm assuming the new room_type column is null for all rows until we fill in it. This will cause incorrect results to be returned until the background update is complete -- do we think this is "fine" until it is done?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is "fine" though I am not sure if I should be the one to judge that

Not sure if this could be avoided anyway

Copy link
Member

Choose a reason for hiding this comment

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

I think for this use-case it is most likely fine too, just was curious if I had missed a conversation about it.

turt2live added a commit to matrix-org/matrix-spec-proposals that referenced this pull request Aug 3, 2022
matrix-org/synapse#13031 originally added support for the feature to Synapse, which although doesn't include an obvious federation route it does end up sending the field over federation.

[Here](https://github.com/matrix-org/synapse/blob/a6895dd576f96d7fd086fb4128d48ac8a3f098c5/synapse/federation/transport/client.py#L481) the server copies the search filter just before it goes over the wire, which is supplied by through a chain of function calls originating [here](https://github.com/matrix-org/synapse/blob/c6d617641186221829c644204f24654430858826/synapse/rest/client/room.py#L456). 

Additionally, it is clear that this sort of feature would have included federation given the filtering is able to be proxied directly like this (as demonstrated by Synapse above).

As such, this is determined to be a clarification/minor edit to the MSC, not requiring a second MSC to add the functionality.
turt2live added a commit to matrix-org/matrix-spec-proposals that referenced this pull request Aug 4, 2022
matrix-org/synapse#13031 originally added support for the feature to Synapse, which although doesn't include an obvious federation route it does end up sending the field over federation.

[Here](https://github.com/matrix-org/synapse/blob/a6895dd576f96d7fd086fb4128d48ac8a3f098c5/synapse/federation/transport/client.py#L481) the server copies the search filter just before it goes over the wire, which is supplied by through a chain of function calls originating [here](https://github.com/matrix-org/synapse/blob/c6d617641186221829c644204f24654430858826/synapse/rest/client/room.py#L456). 

Additionally, it is clear that this sort of feature would have included federation given the filtering is able to be proxied directly like this (as demonstrated by Synapse above).

As such, this is determined to be a clarification/minor edit to the MSC, not requiring a second MSC to add the functionality.
@clokep clokep mentioned this pull request Sep 29, 2022
13 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants