-
Notifications
You must be signed in to change notification settings - Fork 564
MSC4311: invites and knocks should contain the create event #19722
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 1 commit
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 @@ | ||
| MSC4311: invites and knocks should contain the create event. Contributed by @FrenchGithubUser @Famedly | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,9 @@ def _get_prejoin_state_entries( | |
| self, config: JsonDict | ||
| ) -> Iterable[tuple[str, str | None]]: | ||
| """Get the event types and state keys to include in the prejoin state.""" | ||
| # MSC4311: the create event must always be included in invite/knock state. | ||
| yield EventTypes.Create, "" | ||
|
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.
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. With further understanding as I review this, my guess is no (which is fine, something for another PR)
Contributor
Author
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. indeed, it doesn't cover including the full |
||
|
|
||
| room_prejoin_state_config = config.get("room_prejoin_state") or {} | ||
|
|
||
| # backwards-compatibility support for room_invite_state_types | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |||||
| from synapse.api.constants import ( | ||||||
| EventContentFields, | ||||||
| EventTypes, | ||||||
| JoinRules, | ||||||
| ReceiptTypes, | ||||||
| RelationTypes, | ||||||
| ) | ||||||
|
|
@@ -394,6 +395,83 @@ | |||||
| ) | ||||||
|
|
||||||
|
|
||||||
| class SyncCreateEventInPrejoinStateTestCase(unittest.HomeserverTestCase): | ||||||
| """MSC4311: Tests that m.room.create is present in invite_state and knock_state""" | ||||||
|
|
||||||
| servlets = [ | ||||||
| synapse.rest.admin.register_servlets, | ||||||
| login.register_servlets, | ||||||
| room.register_servlets, | ||||||
| sync.register_servlets, | ||||||
| knock.register_servlets, | ||||||
| ] | ||||||
|
|
||||||
| def default_config(self) -> JsonDict: | ||||||
| config = super().default_config() | ||||||
| return config | ||||||
|
|
||||||
| def test_create_event_present_in_invite_state(self) -> None: | ||||||
|
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. For reference, it looks like we also have It looks like that test already passes on
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. It looks like this is a combination of MSC1772 but it was only a recommendation. And MSC4311 changes that to a requirement Lines 94 to 95 in 93e0497
And then there was a flawed partial MSC4311 implementation introduced in 0eb7252. I'm reverting that change in #19723 |
||||||
| """m.room.create must appear in invite_state.""" | ||||||
| inviter = self.register_user("inviter", "pass") | ||||||
| inviter_tok = self.login("inviter", "pass") | ||||||
| invitee = self.register_user("invitee", "pass") | ||||||
| invitee_tok = self.login("invitee", "pass") | ||||||
|
|
||||||
| room_id = self.helper.create_room_as(inviter, tok=inviter_tok) | ||||||
| self.helper.invite( | ||||||
| room=room_id, src=inviter, targ="@invitee:test", tok=inviter_tok | ||||||
|
FrenchGithubUser marked this conversation as resolved.
Outdated
|
||||||
| ) | ||||||
|
|
||||||
| channel = self.make_request("GET", "/sync", access_token=invitee_tok) | ||||||
| self.assertEqual(channel.code, 200, channel.json_body) | ||||||
|
|
||||||
| invite_state_events = channel.json_body["rooms"]["invite"][room_id][ | ||||||
| "invite_state" | ||||||
| ]["events"] | ||||||
| event_types = {e["type"] for e in invite_state_events} | ||||||
|
FrenchGithubUser marked this conversation as resolved.
Outdated
|
||||||
| self.assertIn(EventTypes.Create, event_types) | ||||||
|
|
||||||
| def test_create_event_present_in_knock_state(self) -> None: | ||||||
| """m.room.create must appear in knock_state.""" | ||||||
| host = self.register_user("host", "pass") | ||||||
| host_tok = self.login("host", "pass") | ||||||
| knocker = self.register_user("knocker", "pass") | ||||||
| knocker_tok = self.login("knocker", "pass") | ||||||
|
|
||||||
| room_id = self.helper.create_room_as( | ||||||
| host, is_public=False, room_version="7", tok=host_tok | ||||||
| ) | ||||||
| self.helper.send_state( | ||||||
| room_id, | ||||||
| EventTypes.JoinRules, | ||||||
| {"join_rule": JoinRules.KNOCK}, | ||||||
| tok=host_tok, | ||||||
| ) | ||||||
|
|
||||||
| channel = self.make_request("GET", "/sync", access_token=knocker_tok) | ||||||
| self.assertEqual(channel.code, 200, channel.json_body) | ||||||
| next_batch = channel.json_body["next_batch"] | ||||||
|
FrenchGithubUser marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| channel = self.make_request( | ||||||
| "POST", | ||||||
| f"/_matrix/client/r0/knock/{room_id}", | ||||||
| b"{}", | ||||||
| knocker_tok, | ||||||
| ) | ||||||
|
FrenchGithubUser marked this conversation as resolved.
Outdated
|
||||||
| self.assertEqual(200, channel.code, channel.result) | ||||||
|
|
||||||
| channel = self.make_request( | ||||||
| "GET", f"/sync?since={next_batch}", access_token=knocker_tok | ||||||
| ) | ||||||
| self.assertEqual(channel.code, 200, channel.json_body) | ||||||
|
|
||||||
| knock_state_events = channel.json_body["rooms"]["knock"][room_id][ | ||||||
| "knock_state" | ||||||
| ]["events"] | ||||||
| event_types = {e["type"] for e in knock_state_events} | ||||||
| self.assertIn(EventTypes.Create, event_types) | ||||||
|
|
||||||
|
|
||||||
| class UnreadMessagesTestCase(unittest.HomeserverTestCase): | ||||||
| servlets = [ | ||||||
| synapse.rest.admin.register_servlets, | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.