Skip to content
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

Add the ability to filter by state event type on admin room state endpoint #18035

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

H-Shay
Copy link
Contributor

@H-Shay H-Shay commented Dec 16, 2024

Adds a query param type to /_synapse/admin/v1/rooms/{room_id}/state that filters the state event query by state event type.

@H-Shay H-Shay requested a review from a team as a code owner December 16, 2024 21:48
@github-actions github-actions bot deployed to PR Documentation Preview December 16, 2024 21:50 Active
@github-actions github-actions bot deployed to PR Documentation Preview December 16, 2024 21:51 Active
synapse/rest/admin/rooms.py Outdated Show resolved Hide resolved
docs/admin_api/rooms.md Outdated Show resolved Hide resolved
changelog.d/18035.feature Outdated Show resolved Hide resolved
tests/rest/admin/test_room.py Show resolved Hide resolved
tests/rest/admin/test_room.py Outdated Show resolved Hide resolved
@github-actions github-actions bot deployed to PR Documentation Preview January 2, 2025 21:13 Active
@H-Shay H-Shay requested a review from anoadragon453 January 3, 2025 00:10
Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

room_id = self.helper.create_room_as(self.admin_user, tok=self.admin_user_tok)

channel = self.make_request(
"GET",
f"/_synapse/admin/v1/rooms/{room_id}/state?type=m.something.else",
f"/_synapse/admin/v1/rooms/{room_id}/state?type=''",
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 this would just be:

Suggested change
f"/_synapse/admin/v1/rooms/{room_id}/state?type=''",
f"/_synapse/admin/v1/rooms/{room_id}/state?type=",

else you'll end up with type = "''".

Copy link
Member

@anoadragon453 anoadragon453 Jan 3, 2025

Choose a reason for hiding this comment

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

Turns out if you do ?type=, then you indeed end up with type = "".

Of course, then we end up ignoring type altogether due do the if type, which is falsy for an empty string.

https://github.com/H-Shay/hq_synapse/blob/25c0726c330ee65b04779c25d69ea3f13fa4a17a/synapse/rest/admin/rooms.py#L468-L474

So all state is returned, and test_room_state_param_empty fails.

I think this behaviour makes sense (ignore if empty string) rather than having no results returned. You can't have an empty type for an event, so this is an invalid parameter value.

If you agree, could you update the test to say that 5 results should have been returned, such that it passes?

@github-actions github-actions bot deployed to PR Documentation Preview January 3, 2025 15:05 Active
@H-Shay H-Shay force-pushed the shay/admin_filter_state branch from 25c0726 to 46d5240 Compare January 3, 2025 18:03
@github-actions github-actions bot deployed to PR Documentation Preview January 3, 2025 18:04 Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants