Allow MSC4155 to work if m.invite_permission_config was previously set (#20476)

Allow MSC4155 to work if m.invite_permission_config was previously set

Fixes #20474
This commit is contained in:
Will Hunt authored and GitHub committed 2026-11-05 15:11:10 +00:00
1 parent 8e1e7dc0af
commit 72a27d71db
3 files changed
+37 -3

No files matched your search

+1
View File
@@ -0,0 +1 @@
Fix a bug introduced in Synapse 1.149.0 where an empty `m.invite_permission_config` account data event would take precedence over [MSC4155](https://github.com/matrix-org/matrix-spec-proposals/pull/4155) invite filtering rules.
@@ -575,9 +575,9 @@ class AccountDataWorkerStore(PushRulesWorkerStore, CacheInvalidationWorkerStore)
data = await self.get_global_account_data_by_type_for_user(
user_id, AccountDataTypes.INVITE_PERMISSION_CONFIG
)
# If the user has an MSC4380-style config setting, prioritise that
# above an MSC4155 one
if data is not None:
# If the user has an MSC4380-style config setting AND has indicated
# a preference within it (no empty dict), prioritise that above an MSC4155 one.
if data:
return MSC4380InviteRulesConfig.from_account_data(data)
if self._msc4155_enabled:
+33
View File
@@ -680,6 +680,39 @@ class TestMSC4380InviteBlocking(FederatingHomeserverTestCase):
)
)
@override_config({"experimental_features": {"msc4155_enabled": True}})
def test_msc4380_empty_config_falls_back_to_msc4155(self) -> None:
"""Test that an empty MSC4380 config does not take precedence over an
MSC4155 config."""
room_id = self.helper.create_room_as(self.alice, tok=self.alice_token)
self.get_success(
self.store.add_account_data_for_user(
self.bob,
AccountDataTypes.INVITE_PERMISSION_CONFIG,
{},
)
)
self.get_success(
self.store.add_account_data_for_user(
self.bob,
AccountDataTypes.MSC4155_INVITE_PERMISSION_CONFIG,
{"blocked_users": [self.alice]},
)
)
f = self.get_failure(
self.handler.update_membership(
requester=create_requester(self.alice),
target=UserID.from_string(self.bob),
room_id=room_id,
action=Membership.INVITE,
),
SynapseError,
).value
self.assertEqual(f.code, 403)
self.assertEqual(f.errcode, "M_INVITE_BLOCKED")
def test_msc4380_block_invite_remote(self) -> None:
"""Test that MSC4380 will block a user from being invited to a room by a remote user."""
# A remote user who sends the invite