Fix missing conditional for registering `on_remove_user_third_party_identifier` module api callbacks (#15227
This commit is contained in:
parent
9418344db4
commit
e157c63f68
|
@ -0,0 +1 @@
|
||||||
|
Fix a bug introduced in Synapse 1.79.0rc1 where attempting to register a `on_remove_user_third_party_identifier` module API callback would be a no-op.
|
|
@ -247,6 +247,11 @@ class ThirdPartyEventRules:
|
||||||
on_add_user_third_party_identifier
|
on_add_user_third_party_identifier
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if on_remove_user_third_party_identifier is not None:
|
||||||
|
self._on_remove_user_third_party_identifier_callbacks.append(
|
||||||
|
on_remove_user_third_party_identifier
|
||||||
|
)
|
||||||
|
|
||||||
async def check_event_allowed(
|
async def check_event_allowed(
|
||||||
self,
|
self,
|
||||||
event: EventBase,
|
event: EventBase,
|
||||||
|
|
|
@ -941,18 +941,16 @@ class ThirdPartyRulesTestCase(unittest.FederatingHomeserverTestCase):
|
||||||
just before associating and removing a 3PID to/from an account.
|
just before associating and removing a 3PID to/from an account.
|
||||||
"""
|
"""
|
||||||
# Pretend to be a Synapse module and register both callbacks as mocks.
|
# Pretend to be a Synapse module and register both callbacks as mocks.
|
||||||
third_party_rules = self.hs.get_third_party_event_rules()
|
|
||||||
on_add_user_third_party_identifier_callback_mock = Mock(
|
on_add_user_third_party_identifier_callback_mock = Mock(
|
||||||
return_value=make_awaitable(None)
|
return_value=make_awaitable(None)
|
||||||
)
|
)
|
||||||
on_remove_user_third_party_identifier_callback_mock = Mock(
|
on_remove_user_third_party_identifier_callback_mock = Mock(
|
||||||
return_value=make_awaitable(None)
|
return_value=make_awaitable(None)
|
||||||
)
|
)
|
||||||
third_party_rules._on_threepid_bind_callbacks.append(
|
third_party_rules = self.hs.get_third_party_event_rules()
|
||||||
on_add_user_third_party_identifier_callback_mock
|
third_party_rules.register_third_party_rules_callbacks(
|
||||||
)
|
on_add_user_third_party_identifier=on_add_user_third_party_identifier_callback_mock,
|
||||||
third_party_rules._on_threepid_bind_callbacks.append(
|
on_remove_user_third_party_identifier=on_remove_user_third_party_identifier_callback_mock,
|
||||||
on_remove_user_third_party_identifier_callback_mock
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Register an admin user.
|
# Register an admin user.
|
||||||
|
@ -1008,12 +1006,12 @@ class ThirdPartyRulesTestCase(unittest.FederatingHomeserverTestCase):
|
||||||
when a user is deactivated and their third-party ID associations are deleted.
|
when a user is deactivated and their third-party ID associations are deleted.
|
||||||
"""
|
"""
|
||||||
# Pretend to be a Synapse module and register both callbacks as mocks.
|
# Pretend to be a Synapse module and register both callbacks as mocks.
|
||||||
third_party_rules = self.hs.get_third_party_event_rules()
|
|
||||||
on_remove_user_third_party_identifier_callback_mock = Mock(
|
on_remove_user_third_party_identifier_callback_mock = Mock(
|
||||||
return_value=make_awaitable(None)
|
return_value=make_awaitable(None)
|
||||||
)
|
)
|
||||||
third_party_rules._on_threepid_bind_callbacks.append(
|
third_party_rules = self.hs.get_third_party_event_rules()
|
||||||
on_remove_user_third_party_identifier_callback_mock
|
third_party_rules.register_third_party_rules_callbacks(
|
||||||
|
on_remove_user_third_party_identifier=on_remove_user_third_party_identifier_callback_mock,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Register an admin user.
|
# Register an admin user.
|
||||||
|
@ -1039,6 +1037,9 @@ class ThirdPartyRulesTestCase(unittest.FederatingHomeserverTestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(channel.code, 200, channel.json_body)
|
self.assertEqual(channel.code, 200, channel.json_body)
|
||||||
|
|
||||||
|
# Check that the mock was not called on the act of adding a third-party ID.
|
||||||
|
on_remove_user_third_party_identifier_callback_mock.assert_not_called()
|
||||||
|
|
||||||
# Now deactivate the user.
|
# Now deactivate the user.
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"PUT",
|
"PUT",
|
||||||
|
|
Loading…
Reference in New Issue